I am experimenting to Joda time.
final String string_from_3rd_party = "GMT+08:00";
// Works for standard Java TimeZone!
System.out.println(TimeZone.getTimeZone(string_from_3rd_party));
// Exception in thread "main" java.lang.IllegalArgumentException: The datetime zone id is not recognised: GMT+08:00
System.out.println(DateTimeZone.forID(string_from_3rd_party));
How can I retain the string_from_3rd_party
, yet, able to construct a Joda DateTimeZone
out from it?
You can use the Java TimeZone to create the DateTimeZone:
TimeZone timeZone = TimeZone.getTimeZone(string_from_3rd_party);
DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(timeZone);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With