Here you can find the source of getCurrentDate()
public static String getCurrentDate()
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getCurrentDate() { Calendar date1 = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(date1.getTime()); }//from w w w . ja v a2 s .c o m public static String getCurrentDate(boolean bool) { Calendar date1 = Calendar.getInstance(); if (bool) { date1.add(Calendar.DATE, -1); } else { date1.add(Calendar.DATE, 1); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(date1.getTime()); } public static String getCurrentDate(boolean bool, String currentDate) { Calendar date1 = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = null; try { date = sdf.parse(currentDate); } catch (ParseException e) { e.printStackTrace(); } date1.setTime(date); if (bool) { date1.add(Calendar.DATE, -1); } else { date1.add(Calendar.DATE, 1); } return sdf.format(date1.getTime()); } }