Here you can find the source of getNowDate()
public static String getNowDate()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**//from ww w . ja v a 2s. co m * return current date value in format: yyyy-MM-dd * * @return String value */ public static String getNowDate() { return dateToStringWithPattern(new Date(), "yyyy-MM-dd"); } /** * return time value of specified date * * @param date the specified date to convert * @param pattern time format * @return String value */ public static String dateToStringWithPattern(Date date, String pattern) { try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(date); } catch (Exception e) { return ""; } } }