如何处理由于时区偏移转换而导致的 jodatime 非法即时
我想将joda设置为今天凌晨2点(请参阅下面的示例代码)。但是我得到了这个例外:DateTime
Exception in thread "main" org.joda.time.IllegalFieldValueException: Value 2 for hourOfDay is not supported: Illegal instant due to time zone offset transition: 2011-03-27T02:52:05.239 (Europe/Prague)
at org.joda.time.chrono.ZonedChronology$ZonedDateTimeField.set(ZonedChronology.java:469)
at org.joda.time.MutableDateTime.setHourOfDay(MutableDateTime.java:702)
处理上述异常或在一天中的特定时间创建 异常 的正确方法是什么?DateTime
示例代码:
MutableDateTime now = new MutableDateTime();
now.setHourOfDay(2);
now.setMinuteOfHour(0);
now.setSecondOfMinute(0);
now.setMillisOfSecond(0);
DateTime myDate = now.toDateTime();
谢谢。