SimpleDateFormat Second in Minute Example in java

This example shows you how to get the Current date with seconds in minute using SimpleDateFormat object.

package com.java.connect.date;
 
import java.text.SimpleDateFormat;
import java.util.Calendar;
 
public class SimpleDateFormatSecondInMinuteExample {
    public static void main(String[] args) {
        // Get the simple date format object by passing the format in string
        SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
        // get the date in String format by passing current date
        // in format method of simple date format object
        Calendar originalDate = Calendar.getInstance();
        System.out.println("The original date is : " + originalDate.getTime());
        String dateString = format.format(originalDate.getTime());
        // Print the formated date.
        System.out.println("The current date with Seconds in minutes is : " + dateString);
 
    }
}

The output of the above example will be as:

The original date is : Sun May 08 06:21:17 GMT 2011
The current date with Seconds in minutes is : 08-05-2011 06:21:17