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


时间格式的问题:

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)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM