Here you can find the source of printNow()
public static String printNow()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** yyyy-MM-dd HH:mm:ss */ public static final String PATNER_DEFAULT = "yyyy-MM-dd HH:mm:ss"; public static String printNow() { return toString(currentDate()); }//from ww w.j a v a 2s . co m public static String toString(Date now) { SimpleDateFormat formatTime = new SimpleDateFormat(PATNER_DEFAULT); if (now == null) return ""; return formatTime.format(now); } public static Date currentDate() { return new Date(); } public static String format(Date date, String formatter) { SimpleDateFormat formatTime = new SimpleDateFormat(formatter); return formatTime.format(date); } }