Here you can find the source of getDatetime()
public static String getDatetime()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static final String FORMAT_DATETIME = "yyyy-MM-dd HH:mm:ss"; public static String getDatetime() { Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATETIME); return sdf.format(calendar.getTime()); }/*from w w w .j a v a2 s. co m*/ }