Here you can find the source of getCurrentDay()
public static String getCurrentDay()
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.Map; public class Main { private static String DEFAULT_PATTERN = "yyyy-MM-dd"; private static Map<String, SimpleDateFormat> formats; /**/*w ww .j a v a2 s . com*/ * @return yyyy-MM-dd */ public static String getCurrentDay() { return format(new Date(), DEFAULT_PATTERN); } /** * * @param date * * @param pattern * * @return */ public static String format(Date date, String pattern) { if (!formats.containsKey(pattern)) pattern = DEFAULT_PATTERN; DateFormat format = formats.get(pattern); return format.format(date); } /** * @param date * @return String */ public static String format(Date date) { Iterator<SimpleDateFormat> iter = formats.values().iterator(); while (iter.hasNext()) { return iter.next().format(date); } return null; } }