Here you can find the source of todayDate()
static public String todayDate()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.*; public class Main { static public String todayDate() { Calendar now = Calendar.getInstance(); now.setTime(new java.util.Date()); return String.valueOf(now.get(Calendar.DAY_OF_MONTH)) + "-" + String.valueOf(now.get(Calendar.MONTH) + 1) + "-" + String.valueOf(now.get(Calendar.YEAR)); }//ww w. j a v a 2s. co m static public String todayDate(String format) { Calendar now = Calendar.getInstance(); now.setTime(new java.util.Date()); return date2String(now.getTime(), format); } public static String date2String(Date date) { if (date == null) return ""; SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"); return format.format(date); } public static String date2String(Date date, String format) { if (date == null) return ""; SimpleDateFormat sdformat = new SimpleDateFormat(format); return sdformat.format(date); } }