Here you can find the source of getCurrentDate(String pattern)
public static String getCurrentDate(String pattern)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getCurrentDate(String pattern) { SimpleDateFormat datePattern = null; if (null == pattern || "".equals(pattern)) { datePattern = new SimpleDateFormat("yyyyMMdd"); } else {/* w ww .ja va 2 s . co m*/ datePattern = new SimpleDateFormat(pattern); } return datePattern.format(new Date()); } }