Java Convert Date to StringWe can convert Date to String in java using format() method of java.text.DateFormat class. format() method of DateFormatThe 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 ExampleLet's see the simple code to convert Date to String in java. Example: Test it NowOutput: 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 NowOutput: 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 Next TopicJava String to char |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India