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