Here you can find the source of now()
public static Date now()
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static String now(String format) { SimpleDateFormat f = new SimpleDateFormat(format); return f.format(new Date()); }/* w w w . j av a2 s. c om*/ public static Date now() { return new Date(); } public static String format(Date d, String format) { return format(d, format, Locale.getDefault()); } public static String format(Date d, String format, Locale locale) { if (d == null) return ""; DateFormat df = new SimpleDateFormat(format, locale); return df.format(d); } }