我正在试验Joda的时间.
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));
Run Code Online (Sandbox Code Playgroud)
我如何保留string_from_3rd_party,但能够从中构建一个Joda DateTimeZone?
小智 22
您可以使用Java TimeZone创建DateTimeZone:
TimeZone timeZone = TimeZone.getTimeZone(string_from_3rd_party);
DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(timeZone);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6865 次 |
| 最近记录: |