Back to project page DisposableIncome-OldJava.
The source code is released under:
MIT License
If you think the Android project DisposableIncome-OldJava listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.co.wilka.disposableincome; /* ww w . j a va 2s .c o m*/ import java.util.Calendar; import java.util.Date; public class WithdrawDateComparer { private final IProvideCalendar calendarProvider; public WithdrawDateComparer(IProvideCalendar calendarProvider) { this.calendarProvider = calendarProvider; } public boolean isBeforeThisMonth(CashWithdraw withdraw) { Date now = calendarProvider.getCalendar().getTime(); if(withdraw.getDate().getYear() < now.getYear()) return true; if(withdraw.getDate().getYear() > now.getYear()) return false; return withdraw.getDate().getMonth() < now.getMonth(); } public boolean isAfterThisMonth(CashWithdraw withdraw) { Date now = calendarProvider.getCalendar().getTime(); if(withdraw.getDate().getYear() < now.getYear()) return false; if(withdraw.getDate().getYear() > now.getYear()) return true; return withdraw.getDate().getMonth() > now.getMonth(); } public boolean isInThePast(CashWithdraw withdraw) { return withdraw.getDate().before(Calendar.getInstance().getTime()); } public boolean isThisMonth(CashWithdraw withdraw) { Date now = calendarProvider.getCalendar().getTime(); return withdraw.getDate().getYear() == now.getYear() && withdraw.getDate().getMonth() == now.getMonth(); } // TODO: Add unit tests for this public int getDaysUntilMonthEnd() { Calendar calendar = calendarProvider.getCalendar(); int daysUntilMonthEnd = calendar.getActualMaximum(Calendar.DAY_OF_MONTH) - calendar.get(Calendar.DAY_OF_MONTH); if(daysUntilMonthEnd == 0) { daysUntilMonthEnd = 1; } return daysUntilMonthEnd; } }