Android: compare calendar dates
android, date, java
Solution
Change them to time in mseconds and compare:
Calendar c = Calendar.getInstance();
c.set(Calendar.MONTH, Calendar.MARCH);
c.set(Calendar.DAY_OF_MONTH, 3);
long time2= c.getTimeInMillis();
c.set(Calendar.MONTH, Calendar.AUGUST);
c.set(Calendar.DAY_OF_MONTH, 8);
long time3= c.getTimeInMillis();
if(time>time2){
//Logic
if(time>time3){
//Logic
}
}
Problem
In my app I´m saving when I last updated some data from my server. Therefore I used: ``` long time = Calendar.getInstance().getTimeInMillis(); ``` Now I want that the data is updated twice a year at 03.03 and 08.08. How can I check wheater one of these two date boarders were crossed since last update?