Here you can find the source of now()
public static String now()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String now() { return datetimeToStr(new Date()); }/* w w w . j av a 2 s .c o m*/ // =============================================================== public static String datetimeToStr(Date dtSource) { // 'yyyy-mm-dd hh:nn:ss' SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); return formatter.format(dtSource); } }