Currently, I have 2 Date objects. Both are generated in same device using same locale.
1 is generated using
SimpleDateFormat FORMATTER = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z");
Date date1 = FORMATTER.parse(date_string);
Another is generated using
Date date2 = new Date();
Now, I would like to compare whether 2 dates are the same day.
According to Comparing two java.util.Dates to see if they are in the same day, I could use
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal2.setTime(date2);
boolean sameDay = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);
Since I'm running the code in mobile devices which resources are limited, I was wondering, what could possibility goes wrong, if I were using Date's deprecated method?
date1.getYear() == date2.getYear() && date1.getMonth() == date2.getMonth() && date1.getDate() == date2.getDate()
http://user.xmission.com/~goodhill/dates/datedeprecation.htm
I know many people talk about Date
alone doesn't handle internationalization well. But, in the above scenario, is there any solid example can prove that, thing can go wrong if I were using deprecated methods?