Home » Java Convert String to Date

Java Convert String to Date

by Online Tutorials Library

Java String to Date

We can convert String to Date in java using parse() method of DateFormat and SimpleDateFormat classes.

Java Convert String to Date

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.

Test it Now

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.

Test it Now

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 

You may also like