Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Preferences preferences = new Preferences(this);
- int beginningOfMonth = preferences.getBeginningMonth();
- //Go back from today to the last <beginningOfMonth> before the oldest transaction
- while(calendar.get(Calendar.DAY_OF_MONTH)!=beginningOfMonth) {
- calendar.add(Calendar.DAY_OF_MONTH, -1);
- }
- //Instance for end date
- Calendar end = Calendar.getInstance();
- do{
- //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
- //the current date
- end.setTime(calendar.getTime());
- end.add(Calendar.MONTH, 1);
- end.add(Calendar.DAY_OF_MONTH, -1);
- 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))) {
- end = Calendar.getInstance();
- }
- mDateInfos.add(new DateInfo(calendar.get(Calendar.YEAR), calendar.get(Calendar.DAY_OF_YEAR), end.get(Calendar.YEAR), end.get(Calendar.DAY_OF_YEAR)));
- calendar.add(Calendar.MONTH, 1);
- } 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