Here you can find the source of getCurrentTime()
public static String getCurrentTime()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getCurrentTime() { java.util.Calendar cal = java.util.Calendar.getInstance(); return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime()); }/*www . jav a2 s. com*/ public static String format(Date date, String pattern) { if (date == null) { return null; } SimpleDateFormat sf = new SimpleDateFormat(pattern); return sf.format(date); } public static String format(Date date) { return format(date, "yyyy-MM-dd"); } }