问题
How to extract time zone from ISO-8601 date string in Java 8.
e.g:
String timestamp1 = "2014-02-15T01:02:03Z" ;
String timestamp2 = "2017-10-27T16:22:27.605-05:30";
Thanks.
回答1:
Use ZonedDateTime:
ZonedDateTime.parse("2017-10-27T16:22:27.605-05:30").getZone()
to get an instance of ZoneId.
Alternatively you can use getOffset()
to obtain ZoneOffset,which is more handy if you need to access the timezone offset in a numeric form.
来源:https://stackoverflow.com/questions/46216099/extract-timezone-from-iso8601-date-time-string