Monday, 25 July 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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...