Here you can find the source of getCurrentDay()
Method: get current day[year-month-day] type string
public static String getCurrentDay()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public static final String YEAR_MONTH_DAY = "yyyy-MM-dd"; public static final String YEAR_MONTH_DAY_HOUR_MINUTE_SECOND = "yyyy-MM-dd HH:mm:ss"; /**/*from w w w.ja va 2 s . co m*/ * <p> * Method: get current day[year-month-day] type string * </p> * * @return String */ public static String getCurrentDay() { return formatCurrentTime(YEAR_MONTH_DAY); } /** * format the current time * * @param format * @return String */ public static String formatCurrentTime(final String format) { return dateToString(getTime(), format); } /** * format date to string format:yyyy-MM-dd HH:mm:ss * * @param date * @return String */ public static String dateToString(final Date date) { return dateToString(date, YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); } /** * format date to string * * @param date * @param format * @return String */ public static String dateToString(final Date date, final String format) { return dateToString(date, format, null); } /** * format date to string * * @param date * @param format * @param locale * @return String */ public static String dateToString(final Date date, final String format, Locale locale) { SimpleDateFormat sdf = new SimpleDateFormat(format, locale == null ? Locale.getDefault() : locale); return sdf.format(date); } /** * <p> * Method: get current date type Date * </p> * * @return java.util.Date */ public static Date getTime() { Calendar calendar = Calendar.getInstance(Locale.getDefault()); return calendar.getTime(); } /** * <p> * Method: get current date type Date * </p> * * @param locale * @return java.util.Date */ public static Date getTime(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } Calendar calendar = Calendar.getInstance(locale); return calendar.getTime(); } }