時間格式的問題:
String a = "2015-11-11 13:11:11";
System.out.println("The first one:");
Date date1 = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss").parse(a);
System.out.println(date1);
System.out.println("The second:");
Date date2 = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss").parse(a);
System.out.println(date2);
System.out.println("The third:");
Date date3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(a);
System.out.println(date3);
output:
The first one:
Sun Dec 28 13:11:11 CST 2014
The second:
Sun Jan 11 13:11:11 CST 2015
The second:
Wed Nov 11 13:11:11 CST 2015
注:
YYYY specifies the week of the year (ISO) while yyyy specifies the calendar year (Gregorian)