Enter your keyword

post

Get Current Date using Java

Below code give current date in String.

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class CurrentDate {
    public CurrentDate() {
        super();
    }

    public static void main(String[] args) {
        DateFormat dateFormat = new SimpleDateFormat(“dd/MM/yyyy HH:mm:ss”);
                Calendar cal = Calendar.getInstance();             
                System.out.println(dateFormat.format(cal.getTime()));
    }
}

Leave a Reply

Your email address will not be published.