Here you can find the source of getCurrentTime(String pattern)
public static String getCurrentTime(String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String PATTERN = "yyyy-MM-dd"; public static String getCurrentTime() { return getCurrentTime(null); }/*from w w w.j a v a2s . c om*/ public static String getCurrentTime(String pattern) { return parseDate2String(new Date(), pattern); } public static String parseDate2String(Date date, String pattern) { return getSimpleDateFormatInstance(pattern).format(date); } public static String parseDate2String(Date date) { return parseDate2String(date, null); } private static SimpleDateFormat getSimpleDateFormatInstance(String pattern) { return new SimpleDateFormat(pattern == null ? PATTERN : pattern); } }