Here you can find the source of getTodayDateString()
public static String getTodayDateString()
//package com.java2s; import java.util.Calendar; public class Main { public static String getTodayDateString() { Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR); int month = now.get(Calendar.MONTH) + 1; int day = now.get(Calendar.DAY_OF_MONTH); String monthStr = String.valueOf(month); String dayStr = String.valueOf(day); if (month < 10) { monthStr = "0" + dayStr; }/*from www .ja v a 2 s . co m*/ if (day < 10) { dayStr = "0" + dayStr; } String nowDate = year + "-" + monthStr + "-" + dayStr; return nowDate; } }