且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

转换EEE MMM dd HH:mm:ss ZZZ yyyy到YYYY-MM-dd JAVA

更新时间:2023-02-26 20:39:22

Date对象不包含有关所需显示格式的任何信息。因此,从格式化的日期字符串解析日期不会记住任何格式。

The Date object does not hold any information about the display format you want. So parsing a date from a formatted date string is not going to 'remember' any formatting.

System.out.println(date3)将使用java的toString打印date3的值方法。

System.out.println(date3) will print value of date3 using java's toString method.

您在date2中有格式化的日期字符串。所以System.out.println(date2)应该给你正确的值。

You have the formatted date string in date2. So System.out.println(date2) should give you the right value.