Skip to content
Advertisement

Tag: datetime-conversion

converting epoch to ZonedDateTime in Java

How to convert epoch like 1413225446.92000 to ZonedDateTime in java? The code given expects long value hence this will throw NumberFormatException for the value given above. Answer java.time can directly parse your string Edit: If your millisecond value is always non-negative, the following DateTimeFormatter can parse it. Now parsing into a ZonedDateTime is just one method call: Output is: 2014-10-13T11:37:26.920-07:00[America/Los_Angeles]

Advertisement