Guest User

Untitled

a guest
May 16th, 2012
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. Preferences preferences = new Preferences(this);
  2.                 int beginningOfMonth = preferences.getBeginningMonth();
  3.                 //Go back from today to the last <beginningOfMonth> before the oldest transaction
  4.                 while(calendar.get(Calendar.DAY_OF_MONTH)!=beginningOfMonth) {
  5.                     calendar.add(Calendar.DAY_OF_MONTH, -1);
  6.                 }
  7.                
  8.                 //Instance for end date
  9.                 Calendar end = Calendar.getInstance();
  10.                
  11.                 do{
  12.                     //We got the start date. Now add one month for the end date. If the end date falls after the current date, then set it to
  13.                     //the current date
  14.                     end.setTime(calendar.getTime());
  15.                     end.add(Calendar.MONTH, 1);
  16.                     end.add(Calendar.DAY_OF_MONTH, -1);
  17.                     if(end.get(Calendar.YEAR)>comparator.get(Calendar.YEAR) || (end.get(Calendar.YEAR)==comparator.get(Calendar.YEAR) && end.get(Calendar.DAY_OF_YEAR)>comparator.get(Calendar.DAY_OF_YEAR))) {
  18.                         end = Calendar.getInstance();
  19.                     }
  20.                    
  21.                     mDateInfos.add(new DateInfo(calendar.get(Calendar.YEAR), calendar.get(Calendar.DAY_OF_YEAR), end.get(Calendar.YEAR), end.get(Calendar.DAY_OF_YEAR)));
  22.                    
  23.                     calendar.add(Calendar.MONTH, 1);
  24.                 } while (calendar.get(Calendar.YEAR)<comparator.get(Calendar.YEAR) || (calendar.get(Calendar.YEAR)==comparator.get(Calendar.YEAR) && calendar.get(Calendar.DAY_OF_YEAR)<=comparator.get(Calendar.DAY_OF_YEAR)));
Advertisement
Add Comment
Please, Sign In to add comment