DateTimeFormat提供的结果与SimpleDateformat不同

时间:2018-11-19 21:31:18

标签: java

为什么DateTimeFormatterSimpleDateFormat给出的结果不同?

String dateString = "0819-03-03";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse(dateString);

System.out.println(sdf.format(date));            

System.out.println(DateTimeFormatter.ISO_LOCAL_DATE.format(
    ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())
));

输出为:

0819-03-03    // SimpleDateFormat    
0819-03-07    // DateTimeFormatter

我怀疑这与日期过长有关。

0 个答案:

没有答案
相关问题