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