Created
January 28, 2013 10:59
-
-
Save fpavageau/4654628 to your computer and use it in GitHub Desktop.
Where you realize java.util.Calendar.add() is not commutative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Calendar cal1 = new GregorianCalendar(2013, Calendar.JANUARY, 28); | |
| Calendar cal2 = new GregorianCalendar(2013, Calendar.JANUARY, 28); | |
| Calendar cal3 = new GregorianCalendar(2013, Calendar.JANUARY, 28); | |
| cal1.add(Calendar.DAY_OF_MONTH, 1); | |
| cal1.add(Calendar.MONTH, 1); | |
| cal2.add(Calendar.MONTH, 1); | |
| cal2.add(Calendar.DAY_OF_MONTH, 1); | |
| cal3.add(Calendar.MONTH, 1); | |
| System.out.println(cal1.getTime().equals(cal2.getTime())); // false | |
| System.out.println(cal1.getTime().after(cal3.getTime())); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment