YYYY-MM-DD 与 yyyy-MM-dd 区别

it2022-05-05  109

时间格式的问题:

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 2014The second:Sun Jan 11 13:11:11 CST 2015The second:Wed Nov 11 13:11:11 CST 2015

注:

YYYY specifies the week of the year (ISO) while yyyy specifies the calendar year (Gregorian)

 

转载于:https://www.cnblogs.com/mucheng/p/6248690.html


最新回复(0)