Here you can find the source of getTodayDate()
public static Date getTodayDate() throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String ENCOUNTER_DATE_PATTERN = "yyyy-M-d"; public static Date getTodayDate() throws ParseException { DateFormat dateFormat = new SimpleDateFormat(ENCOUNTER_DATE_PATTERN); Date date = new Date(); String dateString = dateFormat.format(date); return getDateFromString(dateString); }/* w w w . ja v a2 s. co m*/ public static Date getDateFromString(String dateString) throws ParseException { // All csv imports use the same date format SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ENCOUNTER_DATE_PATTERN); simpleDateFormat.setLenient(false); return simpleDateFormat.parse(dateString); } }