public static int findDaysInBetween(Date startDate, Date endDate){
int noOfDays = 0;
long timeDiff = endDate.getTime() - startDate.getTime();
long noOfDays = timeDiff / (24 * 60 * 60 * 1000) + 1;
noOfDays = (int) noOfDays;
return noOfDays;
}
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
String startDateString = <Give start date here>;
String endDateString = <Give end date here>;
Date startDate = formatter.parse(startDateString);
Date endDate = formatter.parse(endDateString);
System.out.print("No of days :"+ findDaysInBetween(startDate,endDate));
No comments:
Post a Comment