Groovy web console

subscribe to the feed Subscribe
to this
site

Milliseconds to Timestamp Java modern

Published 3 months ago by Marcello de Sales with tags timezone
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts

def instant  = new java.sql.Timestamp(1561411104890).toInstant()
java.time.ZoneId zoneId = java.time.ZoneId.of( "America/Los_Angeles" ); 
java.time.ZonedDateTime zdt = java.time.ZonedDateTime.ofInstant(instant, zoneId);
java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern( "MM-dd-uuuu HH:mm:ss" );
zdt.format(formatter);