import java.util.Date;
public class Comparedates{
public static void main(String[] args) {
Date Date1 = new Date();
try{
Thread.sleep(1000);
}catch(Exception e){
}
Date Date2 = new Date();
System.out.println("First Date:="+Date1);
System.out.println("Second Date:="+Date2);
if(Date1.compareTo(Date2) > 0)
System.out.println("Date1 is Greater than Date2");
else if(Date1.compareTo(Date2) < 0)
System.out.println("Date1 is less than Date2");
else
System.out.println("Date1 and Date2 are equal!!!");
}
}
Loading...
|
Comments :
Post a Comment