Skip to content

Instantly share code, notes, and snippets.

@erikkaplun
Created October 17, 2018 17:53
Show Gist options
  • Save erikkaplun/c97aa1e98ab36fafa67a77f96b8cb202 to your computer and use it in GitHub Desktop.
Save erikkaplun/c97aa1e98ab36fafa67a77f96b8cb202 to your computer and use it in GitHub Desktop.
ZoneId zoneId = null;
try { zoneId = ZoneId.of("Europe/Tallinn"); }
catch(Exception e) {
// what the handler should do when the
// provided URL path contains an invalid zone name
}
// take the current time in the current timezone
LocalDateTime localDateTime = LocalDateTime.now();
// "map" it to
ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, zoneId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment