Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getCurrentDate() { Calendar c = Calendar.getInstance(); System.out.println("Current time => " + c.getTime()); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate = df.format(c.getTime()); return formattedDate; } }