I want to compare two Calendar objects to see if they both contain the same date. I don't care about any value below days.
I've implemented this and I can't think about any case where it should fail:
private static boolean areEqualDays(Calendar c1, Calendar c2) {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
return (sdf.format(c1.getTime()).equals(sdf.format(c2.getTime())));
}
Is this approach correct or should I compare c1 and c2 field by field?
See Question&Answers more detail:os