0

I am working with an application for counting remaining days between two dates,ie there is a start date and end date.I want to calculate remaining days to the end date in each day.Please help me.Thanks

krishna
  • 409
  • 5
  • 16

1 Answers1

2
SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy");
String inputString1 = "23 01 2015";
String inputString2 = "27 04 2015";
try {
Date date1 = myFormat.parse(inputString1);
Date date2 = myFormat.parse(inputString2);
long diff = date2.getTime() - date1.getTime();
System.out.println ("Days: " + TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS));
} catch (ParseException e) {
e.printStackTrace();
}
sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • this code only calculate days between date1 and date2..but i want to find remaining count between end date and start date in each day. – krishna Dec 19 '15 at 07:20