Online Java Compiler By
JavaTpoint.com
import java.util.Date; public class JavaDateCompareToExample3 { public static void main(String[] args) { Date d=new Date(2018,9,21); Date d1=new Date(1997,3,10); int comparison=d.compareTo(d1); System.out.println("Your comparison value is : "+comparison); } }
Output