Here you can find the source of getCurrentDateString(String format)
public static String getCurrentDateString(String format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static final String SYSTEM_DATEFORMAT_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; public synchronized static String getCurrentDateString() { SimpleDateFormat format = new SimpleDateFormat(SYSTEM_DATEFORMAT_YYYY_MM_DD_HH_MM_SS); Date time = GregorianCalendar.getInstance().getTime(); return format.format(time); }//w ww .ja va2 s . c o m public static String getCurrentDateString(String format) { Date time = GregorianCalendar.getInstance().getTime(); return new SimpleDateFormat(format).format(time); } }