Here you can find the source of currentDate()
public static String currentDate()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** The date format string:(yyyy-MM-dd) */ public static final String DATE_FORMAT_STR = "yyyy-MM-dd"; /**/*from ww w. jav a2 s . com*/ * gets current time's string format like "yyyy-MM-dd" * * @return */ public static String currentDate() { return getDateFormat(now()); } /** * getting a date string like 'yyyy-MM-dd' from a java.util.Date or java.sql.Date * * @param date a java.util.Date or java.sql.Date * @return a string like 'yyyy-MM-dd' */ public static String getDateFormat(java.util.Date date) { return getFormat(date, DATE_FORMAT_STR); } /** * Returns the current datetime. * * @return the current datetime. */ public static Date now() { return new Date(System.currentTimeMillis()); } public static String getFormat(java.util.Date date, String parseFormat) { if (null == date) { return null; } if (null == parseFormat || "".equalsIgnoreCase(parseFormat)) { return date.toString(); } return new SimpleDateFormat(parseFormat).format(date); } }