If using Java 8, you can parse it as an Instant
and then convert it to a ZonedDateTime
in the time zone you need. You can then get the local time from the ZonedDateTime
.
Instant instant = Instant.parse("2017-11-22T22:00:00Z");
ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());
System.out.println(zdt.toLocalTime());
You can also specify a specific Zone ID other than the system default. To see the available Zone IDs to choose from, use ZoneId.getAvailableZoneIds())
Using ZonedDateTime
will handle daylight savings. If you simply need a static hour offset, you can convert it to an OffsetDateTime
instead of the ZonedDateTime
.