298
Java String to Date
We can convert String to Date in java using parse() method of DateFormat and SimpleDateFormat classes.
To learn this concept well, you should visit DateFormat and SimpleDateFormat classes.
Java String to Date Example
Let’s see the simple code to convert String to Date in java.
Output:
31/12/1998Thu Dec 31 00:00:00 IST 1998
Let's see another code to convert different types of Strings to Date in java. Here, we have used different date formats using SimpleDateFormat class.
Output:
31/12/1998Thu Dec 31 00:00:00 IST 1998 31-Dec-1998Thu Dec 31 00:00:00 IST 1998 12 31, 1998Thu Dec 31 00:00:00 IST 1998 Thu, Dec 31 1998Thu Dec 31 00:00:00 IST 1998 Thu, Dec 31 1998 23:37:50Thu Dec 31 23:37:50 IST 1998 31-Dec-1998 23:37:50Thu Dec 31 23:37:50 IST 1998
Next TopicJava Date to String