Here you can find the source of now()
public static long now()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static long now() { return System.currentTimeMillis(); }//from w w w . j a v a 2 s. co m public static String now(String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(now()); } public static String format(long t, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(t); } public static String format(Calendar calendar, String format) { return format(calendar.getTimeInMillis(), format); } public static String format(Date date, String format) { return format(date.getTime(), format); } }