Convert Date to String in Java

Many times we need to convert the Date in String format as some of the applications may store the data in String format. In this tutorial we will see how to Convert Date to String in Java with an example.

We will create an instance of SimpleDateFormat which is used for formatting the string representation of date. We will get the today’s date and use the format method of SimpleDateFormat class to get the String out of the date.

Example:

Let’s run this program and check the output.

Output:

In the above program we have taken the SimpleDateFormat class to format today’s date in the String format and we have printed the date in String format.

If you want to convert the String to Date in Java, then read tutorial on Convert String to Date in Java.

Related posts

Leave a Comment