java - How to handle jodatime Illegal instant due to time zone offset transition -
I want to set up 2 hrs Joda Or to create a Sample code is the correct way to handle exceptions above: Thanks. The It seems that you have a This code generates: Time (see below sample code). But I'm getting this exception:
formula exception "main" OrgkjodaktimekIllegalFieldValueException: no 2 supported HOUROFDAY: illegal immediate time zone due to offset transition: 2011 -03-27T02: 52: 05.23 9 (Europe / Prague) org.joda.time.chrono.ZonedChronology $ ZonedDateTimeField.set (ZonedChronology.java:469) on org.joda.time.MutableDateTime.setHourOfDay (MutableDateTime. Java: 702)
date time at a particular time of day?
Now MutableDateTime = new MutableDateTime (); Now.setHourOfDay (2); Now.setMinuteOfHour (0); Now.setSecondOfMinute (0); Now.setMillisOfSecond (0); Date time myDate = now.toDateTime ();
Dinanktaim example And you want to be stronger than Daylight Savings. Try it ... (Note that I am in America / Eastern, so our date of transition was 13 March 11; I got the right date for you to get an exception. Update your code below for the CET, which today The change happens here. The information here is that the add-on tells you about a local wall-clock setting and whether it is legal in your time zone. In this case, I just have to decide if an hour is not present (. If your application does, then this is the right policy)
import org.joda.time.DateTime ; Import org.joda.time.DateTimeZone; Import org.joda.time.LocalDateTime; Class tests {public static zero chief (string [] args) {last datetime timezone = date = datetime. Ford ("CET"); LocalDateTime ldt = new LocalDateTime (DTZ) .withYear (2011) .withMonthOfYear (3) .withDayOfMonth (27) .withHourOfDay (2); // It is just to make it clear that I am solving the problem; // Operational code is not required {try DateTime myDateBorken = ldt.toDateTime (dtz); } Hold (invalid illegal exception iae) {System.out.println ("Definitely, time zone immediately offset due to offset transit!"); } If (dtz.isLocalDateTimeGap (ldt)) {ldt = ldt.withHourOfDay (3); } Date time myDate = ldt.toDateTime (dtz); System.out.println ("no problem:" + myDate); }}
Definitely, due to the time zone offset transition immediately invalid! No problem: 2011-03-27T 03: 00: 00.000 + 02: 00
Comments
Post a Comment