Created
September 4, 2017 15:44
-
-
Save rschumm/012e6fbb8f92321934f3c0cbdb7c96a5 to your computer and use it in GitHub Desktop.
ZonedTimeZone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZonedDateTime zonedDateTime = ZonedDateTime.now(); | |
String token = zonedDateTime.format(DateTimeFormatter.ISO_ZONED_DATE_TIME); | |
System.out.println(token); | |
ZonedDateTime zonedDateTime2 = ZonedDateTime.parse(token, DateTimeFormatter.ISO_ZONED_DATE_TIME); | |
String zeit = zonedDateTime2.format(DateTimeFormatter.ISO_ZONED_DATE_TIME); | |
System.out.println(zeit); | |
long between = ChronoUnit.SECONDS.between(zonedDateTime, zonedDateTime2); | |
System.out.println(between); | |
//andere Zeitzone | |
ZonedDateTime zonedDateTimeWinti = ZonedDateTime.parse("2017-09-04T15:38:50.801+02:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME); | |
ZonedDateTime zonedDateTimeRio = ZonedDateTime.parse("2017-09-04T09:38:50.801-04:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME); | |
long between2 = ChronoUnit.SECONDS.between(zonedDateTimeWinti, zonedDateTimeRio); | |
System.out.println(between2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2017-09-04T15:53:30.894+02:00[Europe/Berlin]
2017-09-04T15:53:30.985+02:00[Europe/Berlin]
2017-09-04T15:53:30.985+02:00[Europe/Berlin]
0
0