Monday, July 25, 2016

How to convert format (2018-04-12T03:00:00.000Z) to Date from java.util package using Java




Hello there im receiveing from frontend a string who has this format (2018-04-12T03:00:00.000Z), so, i have to convert it to Date from Util package using Java.(java.util.Date)



Is there a good way to do this?


Answer



If you are using Java 8+, the easiest way is to use the java.time package to parse the date:



Date date = Date.from(Instant.parse("2018-04-12T03:00:00.000Z"));


No comments:

Post a Comment