[java]代码库
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 如何把日期格式13-4-5 23:02:02.000变成 2013-4-5 23:02:02
*/
public class MyDateFormat {
public static void main(String args[]) throws ParseException {
String timeString = "13-4-5 23:02:02.000";
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS");
Date date = sdf.parse(timeString);
Long time = date.getTime();
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-M-d HH:mm:ss");
System.out.println(sdf2.format(time));
}
}