Here you can find the source of getDate()
public static Date getDate()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getDate() { return java.sql.Date.valueOf(getFormatDate("yyyy-MM-dd")); }// w w w . j ava 2 s.co m public static Date getDate(String date) { return java.sql.Date.valueOf(date); } protected static String getFormatDate(String formatString) { String currentDate = ""; SimpleDateFormat format1 = new SimpleDateFormat(formatString); currentDate = format1.format(new Date()); return currentDate; } }