tags:

views:

15

answers:

1

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?

+2  A: 

You can use the Java TimeZone to create the DateTimeZone:

TimeZone timeZone = TimeZone.getTimeZone(string_from_3rd_party);
DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(timeZone);
Ventral