Epoch time in MicroSeconds : 1529948813696000
how to convert this into java time stamp.
I am able to convert epoch time in MilliSeconds using this method
Instant instant = Instant.ofEpochMilli(Long.parseLong("1529957592000"));
Date parsedDate = dateFormat.parse(instant.atZone(ZoneId.of("America/Chicago")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")).toString())
Need help to convert Epoch time in Microseconds ?
Convert from epoch to human-readable datemyString := DateTimeToStr(UnixToDateTime(Epoch)); Where Epoch is a signed integer. Replace 1526357743 with epoch. =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number).
1. Introduction. In this quick tutorial, we'll learn how to parse representations of dates from a Unix timestamp. Unix time is the number of seconds elapsed since January 1, 1970. However, a timestamp can represent time down to nanosecond precision.
Simply multiply Unix timestamp by 1000 to convert it to a JavaScript time, because Unix timestamp measures time as a number of seconds, whereas in JavaScript time is fundamentally specified as the number of milliseconds (elapsed since January 1, 1970 at 00:00:00 UTC).
Epoch Time Difference FormulaMultiply the two dates' absolute difference by 86400 to get the Epoch Time in seconds – using the example dates above, is 319080600.
While the Instant
class doesn't have an ofEpochNano(long)
method, it does has an overload of ofEpochSecond(long, long)
that accepts a nanosecond offset along with the epoch seconds.
With a little math you can just convert your epoch microseconds to seconds plus an offset and create your Instant
using it, like so:
long epochMicroSeconds = 1_529_948_813_696_123L;
long epochSeconds = epochMicroSeconds / 1_000_000L;
long nanoOffset = ( epochMicroSeconds % 1_000_000L ) * 1_000L ;
Instant instant = Instant.ofEpochSecond( epochSeconds, nanoOffset ) ;
See this code run live at IdeOne.com.
instant.toString(): 2018-06-25T17:46:53.696123Z
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With