Joh*_*hen 3 java syntax date simpledateformat
public static void getTime() {
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
Time t1 = new Time(Long.parseLong("1369213412435"));
Time t2 = new Time(Long.parseLong("1369213412245"));
System.out.println(sdf.format(t1));
System.out.println(sdf.format(t2));
}
Run Code Online (Sandbox Code Playgroud)
为什么打印上面的代码,
2013-05-22 17:03:32
2013-05-22 17:03:32
Run Code Online (Sandbox Code Playgroud)
Bob*_*der 10
这两个日期仅相差毫秒(435或245),您可以在格式中忽略这些日期.
使用:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
Run Code Online (Sandbox Code Playgroud)
看到不同的价值观.