Here you can find the source of nowAsDate()
public static java.sql.Date nowAsDate()
//package com.java2s; import java.util.Calendar; public class Main { public static java.sql.Date nowAsDate() { Calendar objCurrentCalendar = Calendar.getInstance(); StringBuffer sbDateString = new StringBuffer(); int iYear = objCurrentCalendar.get(Calendar.YEAR); int iMonth = objCurrentCalendar.get(Calendar.MONTH) + 1; int iDate = objCurrentCalendar.get(Calendar.DATE); sbDateString.append(iYear);//from www .j a v a2s .co m sbDateString.append("-"); sbDateString.append(iMonth); sbDateString.append("-"); sbDateString.append(iDate); try { return java.sql.Date.valueOf(sbDateString.toString()); } catch (Exception e) { return new java.sql.Date(System.currentTimeMillis()); } } }