Here you can find the source of getNowString(String pattern)
public static String getNowString(String pattern)
//package com.java2s; //License from project: LGPL import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; public class Main { private static final Map<String, SimpleDateFormat> map = new HashMap<String, SimpleDateFormat>(); public static String getNowString(String pattern) { return getDateFormat(pattern).format(getNow()); }/*from w w w. j ava 2 s. c om*/ public static SimpleDateFormat getDateFormat(String pattern) { synchronized (map) { SimpleDateFormat format = map.get(pattern); if (format == null) { format = new SimpleDateFormat(pattern); map.put(pattern, format); } return format; } } public static Date getNow() { return new Date(); } }