Here you can find the source of getCurrentDateAsString()
public synchronized static String getCurrentDateAsString()
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); public synchronized static String getCurrentDateAsString() { return DEFAULT_DATE_FORMAT.format(Calendar.getInstance().getTime()); }//from ww w . j a v a 2s. c om public static String getCurrentDateAsString(String dateFormat) { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.format(Calendar.getInstance().getTime()); } }