Skip to content

Instantly share code, notes, and snippets.

@rschumm
Created September 4, 2017 15:44
Show Gist options
  • Save rschumm/012e6fbb8f92321934f3c0cbdb7c96a5 to your computer and use it in GitHub Desktop.
Save rschumm/012e6fbb8f92321934f3c0cbdb7c96a5 to your computer and use it in GitHub Desktop.
ZonedTimeZone
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);
@rschumm
Copy link
Author

rschumm commented Sep 4, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment