Here you can find the source of getCurrentDateStr()
public static String getCurrentDateStr()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.*; public class Main { public static String getCurrentDateStr() { return formatDate(new Date()); }/* w w w .j a v a2 s . c om*/ public static String getCurrentDateStr(String pattern) { return formatDate(new Date(), pattern); } public static String formatDate(Date date, String pattern) { SimpleDateFormat df = new SimpleDateFormat(pattern); return df.format(date); } public static String formatDate(Date date) { return formatDate(date, "yyyy-MM-dd"); } }