I. Description of the problem
Get a year's time stamp a day for a month by DateTime, then use joda-time of Period.getYears () to compare two years of the time difference. When new DateTime ( "1990-04-15") being given as follows:
threw exception [Request processing failed; nested exception is org.joda.time.IllegalInstantException: Cannot parse "
1986-05-04": Illegal instant due to time zone offset transition (Asia/Shanghai)] with root cause]
org.joda.time.IllegalInstantException: Cannot parse "1986-05-04": Illegal instant due to time zone offset transition (Asia/Shanghai)
at org.joda.time.format.DateTimeParserBucket.computeMillis(DateTimeParserBucket.java:471) ~[joda-time-2.9.4.jar!/:2.9.4]
at org.joda.time.format.DateTimeParserBucket.computeMillis(DateTimeParserBucket.java:411) ~[joda-time-2.9.4.jar!/:2.9.4]
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:928) ~[joda-time-2.9.4.jar!/:2.9.4]
at org.joda.time.DateTime.parse(DateTime.java:160) ~[joda-time-2.9.4.jar!/:2.9.4]
By traversing 1900--2500 Nian all the time found that not all of the time will be given, only 1940-06-03,1941-03-16,1986-05-04,1987-04-12,1988-04-10,1989-04 -16,1990-04-15,1991-04-14 several time there as error thrown ..
Two cause
new DateTime time zone not specified ( "1990-04-15"), making it impossible to find the time stamp corresponding to the time.
Third, the solution
When new DateTime ( "1990-04-15") specify the time zone, such as: new DateTime ( "1990-04-15",
DateTimeZone.forID ( "+ 08:00")) Original: https: //blog.csdn. net / u010954806 / article / details / 79064130