Here you can find the source of getCurrentDateTime()
public static String getCurrentDateTime()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getCurrentDateTime() { return getFormatDateTime(new Date(), "yyyy-MM-dd HH:mm:ss"); }/*w w w. j av a 2 s . c om*/ public static String getFormatDateTime(Date date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }