How to convert String into Date in one line in Java
1810
1 Answer
6 years ago by Divya
You can use java.text.SimpleDateFormat
Class to parse Date Strings in specified formats.
Following is the sample code
Date dateObject = new SimpleDateFormat("yyyy-MM-dd").parse("2017-10-15");
Note: This line will throw the java.text.ParseException
if the String does not match with the pattern
6 years ago by Karthik Divi