(Using Java 11) How can I convert the following epoch long value:
long epochLong = 1496760826841L
into this string:
Jun 6, 2017 3:53:46 PM
(Using Java 11) How can I convert the following epoch long value:
long epochLong = 1496760826841L
into this string:
Jun 6, 2017 3:53:46 PM
This should work if you want Jun 06, 2017 3:53:46 PM
irrespective of the JVM machine time zone change the triggerTime
to this
LocalDateTime triggerTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMillis), ZoneId.of("+01:00"));
public static void main(String[] args) {
long epochMillis = 1496760826841L;
LocalDateTime triggerTime =
LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMillis),
TimeZone.getDefault().toZoneId());
DateTimeFormatter parseFormatter
= DateTimeFormatter.ofPattern("MMM dd, yyyy h:m:s a");
System.out.println(triggerTime.format(parseFormatter));
}