Here you can find the source of getCurrentDateString()
public static String getCurrentDateString() throws Exception
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static String getCurrentDateString() throws Exception { return getCurrentDateString("yyyyMMdd"); }// w w w . j a va 2s .c o m public static String getCurrentDateString(String pattern) throws Exception { return convertToString(getCurrentTimeStamp(), pattern); } public static String convertToString(Timestamp dateData) throws Exception { return convertToString(dateData, "yyyy/MM/dd"); } public static String convertToString(Timestamp dateData, String pattern) throws Exception { return convertToString(dateData, pattern, java.util.Locale.CHINA); } public static String convertToString(Timestamp dateData, String pattern, java.util.Locale locale) throws Exception { try { if (dateData == null) { return null; } SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); //formatter.applyPattern( pattern ); return formatter.format(dateData); } catch (Exception e) { throw new Exception("[DateUtil][convertToString]" + e.getMessage(), e); } } public static Timestamp getCurrentTimeStamp() throws Exception { try { Calendar cal = new GregorianCalendar(); Timestamp result = new Timestamp(cal.getTime().getTime()); return result; } catch (Exception e) { throw new Exception("[DateUtil][getCurrentTimeStamp]" + e.getMessage(), e); } } }