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
Asked
Active
Viewed 1,998 times
0
-
refer http://stackoverflow.com/questions/20165564/calculating-days-between-two-dates-with-in-java and http://stackoverflow.com/questions/23323792/android-days-between-two-dates – Jithin Varghese Dec 19 '15 at 06:54
-
i want to reduce the count in each day – krishna Dec 19 '15 at 07:01
1 Answers
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