Here you can find the source of getNow()
public static String getNow()
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getNow() { return getDate(new Date()); }/*from ww w .j a va 2 s.c o m*/ public static String getDate(Date date) { return format(date, "yyyy-MM-dd"); } public static String format(Date date, String format) { String result = ""; try { if (date != null) { DateFormat dateFormat = new SimpleDateFormat(format); result = dateFormat.format(date); } } catch (Exception localException) { } return result; } public static String format(Date date) { return format(date, "yyyy-MM-dd"); } }