Here you can find the source of getNow()
public static String getNow()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String getNow() { return formatDateTime(new Date()); }/*from ww w . j av a 2s . c o m*/ public static String getNow(String pattern) { return formatDateTime(new Date(), pattern); } public static String formatDateTime(Date d) { return formatDateTime(d, DATETIME_PATTERN); } public static String formatDateTime(Date d, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(d); } }