I needed to convert only the hour part of 12 hour time string to 24 hour format. I’m not interested in other than hour parts of a date string. SimpleDateFormatter is notoriously buggy and I in fact I’m more interested in the conversion algorithm itself. So what I want is to find the algorithm to convert the hour part. This
Tag: datetime-conversion
Convert ZonedDateTime to LocalDateTime at time zone
I have an object of ZonedDateTime that is constructed like this How can I convert it to LocalDateTime at time zone of Switzerland? Expected result should be 16 april 2018 13:30. Answer How can I convert it to LocalDateTime at time zone of Switzerland? You can convert the UTC ZonedDateTime into a ZonedDateTime with the time zone of Switzerland, but
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]