Skip to content

Instantly share code, notes, and snippets.

@jnizet
Created May 26, 2014 19:30
Show Gist options
  • Save jnizet/a5bac068123afdc36421 to your computer and use it in GitHub Desktop.
Save jnizet/a5bac068123afdc36421 to your computer and use it in GitHub Desktop.
Temporal comparison example
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