Here you can find the source of getTodayString()
public static String getTodayString()
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String shortFormat = "yyyyMMdd"; /**//from w ww. ja v a 2s .c o m * yyyyMMdd * * @return */ public static String getTodayString() { DateFormat dateFormat = createNewDateFormat(shortFormat); return formatDateString(new Date(), dateFormat); } public static DateFormat createNewDateFormat(String pattern) { DateFormat df = new SimpleDateFormat(pattern); df.setLenient(false); return df; } public static String formatDateString(Date date, DateFormat dateFormat) { if (date == null || dateFormat == null) { return null; } return dateFormat.format(date); } public static String format(Date date, String format) { if (date == null) { return null; } return new SimpleDateFormat(format).format(date); } }