Created
July 27, 2013 15:42
-
-
Save oleg/6095198 to your computer and use it in GitHub Desktop.
This file contains 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
@Test | |
public void comparing_date_and_timestamp() throws Exception { | |
long millis = 1383057201173L; | |
java.sql.Timestamp timestamp = new java.sql.Timestamp(millis); | |
java.util.Date date = new java.util.Date(millis); | |
//wtf | |
assertTrue(date.equals(timestamp)); | |
assertTrue(date.after(timestamp)); | |
assertFalse(date.before(timestamp)); | |
//wtf | |
assertFalse(timestamp.equals(date)); | |
assertFalse(timestamp.after(date)); | |
assertTrue(timestamp.before(date)); | |
//works as expected | |
assertTrue(timestamp.getTime() == date.getTime()); | |
assertFalse(timestamp.getTime() < date.getTime()); | |
assertFalse(timestamp.getTime() > date.getTime()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment