当我解析 0000 年的日期时,它似乎存储为 0001 年。
代码见下:
String dateStr = "00000102";
System.out.println(dateStr);
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = dateFormat.parse("00000102");
String convertedStr = dateFormat.format(date);
System.out.println(convertedStr);
输出如下:
00000102
00010102
有没有办法使用标准 Java API 在 Java 中表示 0000 年?
最佳答案
我不相信这是可能的,因为 java.util.Date
基于 UTC ,这是基于 Gregorian calendar ,并且公历没有零年。
...the traditional proleptic Gregorian calendar (like the Julian calendar) does not have a year 0 and instead uses the ordinal numbers 1, 2, … both for years AD and BC. Thus the traditional time line is 2 BC, 1 BC, AD 1, and AD 2.
(来源:The Wikipedia article on the Gregorian calendar)
关于java - Java 中的 0000 年,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8440480/