Java SimpleDateFormatThe java.text.SimpleDateFormat class provides methods to format and parse date and time in java. The SimpleDateFormat is a concrete class for formatting and parsing date which inherits java.text.DateFormat class. Notice that formatting means converting date to string and parsing means converting string to date. Java SimpleDateFormat Example: Date to StringLet's see the simple example to format date in java using java.text.SimpleDateFormat class. Output: 13/04/2015 Note: M (capital M) represents month and m (small m) represents minute in java.Let's see the full example to format date and time in java using java.text.SimpleDateFormat class. 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 Java SimpleDateFormat Example: String to DateLet's see the simple example to convert string into date using java.text.SimpleDateFormat class. Output: Date is: Tue Mar 31 00:00:00 IST 2015 Next TopicJava Get Current Date and Time in Java
|