Here you can find the source of now(String pattern)
public static String now(String pattern)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; public class Main { private static final Map<String, DateFormat> patterns = new HashMap<String, DateFormat>(); public static String now(String pattern) { DateFormat dateFormat = getFormat(pattern); return dateFormat.format(new Date()); }//www. j ava 2 s. c o m private static DateFormat getFormat(String pattern) { DateFormat dateFormat; if (!patterns.containsKey(pattern)) { dateFormat = new SimpleDateFormat(pattern); patterns.put(pattern, dateFormat); } dateFormat = patterns.get(pattern); return dateFormat; } }