Here you can find the source of now()
public static String now()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String now() { return formatTime(today()); }/*from w w w. j a v a 2 s .c o m*/ public static String formatTime(Date date) { String dateString = date.toString(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm"); try { dateString = formatter.format(date); } catch (IllegalArgumentException iae) { iae.printStackTrace(); } return dateString; } public static Date today() { return new Date(); } }