Hi I have a problem : from server I get a time and it looks like this :
"date":"2017-05-24T07:56:22Z"
But now in my local time is 09:56:22 how I can convert this ?
Hi I have a problem : from server I get a time and it looks like this :
"date":"2017-05-24T07:56:22Z"
But now in my local time is 09:56:22 how I can convert this ?
First you need to parse the date, for example:
Instant instant = Instant.parse("2017-05-24T07:56:22Z");
Assuming your time zone is correctly set, you can then simply use:
LocalTime localTime = instant.atZone(ZoneId.systemDefault()).toLocalTime();
If you want to use a specific time zone instead of the system default time zone:
LocalTime localTime = instant.atZone(ZoneId.of("Europe/London")).toLocalTime();