Here you can find the source of getCurrentDateString()
public static String getCurrentDateString()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*w ww . j av a 2 s .c o m*/ * Expanded ISO 8601 Date format yyyy-MM-dd i.e., 2002-12-25 for the 25th day of December in the year 2002 */ public static final String ISO_EXPANDED_DATE_FORMAT = "yyyy-MM-dd"; public static String getCurrentDateString(String pattern) { return dateToString(getCurrentDateTime(), pattern); } public static String getCurrentDateString() { return dateToString(getCurrentDateTime(), ISO_EXPANDED_DATE_FORMAT); } public static String dateToString(Date date, String pattern) { if (date == null) { return null; } try { SimpleDateFormat sfDate = new SimpleDateFormat(pattern); sfDate.setLenient(false); return sfDate.format(date); } catch (Exception e) { return null; } } public static String dateToString(Date date) { return dateToString(date, ISO_EXPANDED_DATE_FORMAT); } public static Date getCurrentDateTime() { java.util.Calendar calNow = java.util.Calendar.getInstance(); java.util.Date dtNow = calNow.getTime(); return dtNow; } }