Here you can find the source of getCurrentDate()
public static String getCurrentDate()
//package com.java2s; import java.util.Date; public class Main { public static String getCurrentDate() { String dateStr = null;//from ww w . j a va 2 s . c o m Date date = new Date(); date.getTime(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; int dt = date.getDate(); dateStr = year + "-" + ((month < 10) ? "0" + month : month) + "-" + ((dt < 10) ? "0" + dt : dt); return dateStr; } }