Created
May 26, 2014 19:30
-
-
Save jnizet/a5bac068123afdc36421 to your computer and use it in GitHub Desktop.
Temporal comparison example
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
public class LocalDateExample { | |
public static void main(String[] args) { | |
LocalDate ld1 = LocalDate.now(); | |
LocalDate ld2 = LocalDate.now().plusDays(2); | |
System.out.println("comparison = " + compare(ld1, ld2)); | |
} | |
private static <T extends Temporal> int compare(T t1, T t2) { | |
Comparable<T> c1 = (Comparable<T>) t1; | |
return c1.compareTo(t2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment