Javatpoint Logo
Javatpoint Logo

Java Convert Date to String

We can convert Date to String in java using format() method of java.text.DateFormat class.

Java Convert Date to String

format() method of DateFormat

The format() method of DateFormat class is used to convert Date into String. DateFormat is an abstract class. The child class of DateFormat is SimpleDateFormat. It is the implementation of DateFormat class. The signature of format() method is given below:

Java Date to String Example

Let's see the simple code to convert Date to String in java.

Example:

Test it Now

Output:

Converted String: 2017-24-28 04:24:27

Let's see the full example to convert date and time into String in java using format() method of java.text.SimpleDateFormat class.

Test it Now

Output:

Date Format with MM/dd/yyyy : 04/13/2015
Date Format with dd-M-yyyy hh:mm:ss : 13-4-2015 10:59:26
Date Format with dd MMMM yyyy : 13 April 2015
Date Format with dd MMMM yyyy zzzz : 13 April 2015 India Standard Time
Date Format with E, dd MMM yyyy HH:mm:ss z : Mon, 13 Apr 2015 22:59:26 IST




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA