09-25-2012 01:18 AM
Hi,
In my application there are two buttons previous and next I want to make a code on the clicking on previous button which show the yesterday's date means current date-1 and on clicking on the next button show the tommrow date means current date+1 date
Can any one provide some sample code for this
Thanks in Advance
09-25-2012 01:59 AM
Hi,
do something like this...
int MILLIS_IN_DAY = 1000 * 60 * 60 * 24;
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
String prevDate = dateFormat.format(date.getTime() - MILLIS_IN_DAY);
String currDate = dateFormat.format(date.getTime());
String nextDate = dateFormat.format(date.getTime() + MILLIS_IN_DAY);
System.out.println("Previous date: " + prevDate);
System.out.println("Currnent date: " + currDate);
System.out.println("Next date: " + nextDate);Regards,
pp