Actually in my java program User give Start Date and end Date ex:2012-12-01 and 2012-12-30 and Now we can give result back to between dates of Start date and end date.
If we want every day we can give using the following code…
List<Date> dates = new ArrayList<Date>();
DateFormat formatter = new SimpleDateFormat("yyyy-mm-dd");
String str_date ="2012-12-03";
String end_date ="2012-12-06";
Date startDate = (Date) formatter.parse(str_date);
Date endDate = (Date) formatter.parse(end_date);
Calendar cal = Calendar.getInstance();
Calendar cal1 = Calendar.getInstance();
cal.setTime(startDate);
cal1.setTime(endDate);
int i=0; // use this for alternative date print
while (!cal.equals(cal1)) {
cal.add(Calendar.DATE, 1);
System.out.println(cal.getTime());
}
But it is not the case the Problem is User want only Monday,sunday dates in his Start date and end Date then How to check that one….
For Ex: String userWeeks="SUNDAY,MONDAY";
This is User String then How to Compare Calendar Dates into this userWeeks string.
First thing we can Split the String userWeeks.split(",") then we get separate SUNDAY MONDAY
So How to compare This String into Calendar?
Finally i’m thinking this way is there any issues of my code Please discuss me..