import java.util.*;
public class DateDemoA
{
public static void main(String args[])
{
Date d1=new Date();
System.out.println("Current Date:" + d1);
Date d2=new Date(84,12,01); //YY,MM,DD
System.out.println("Date of Birth:" + d2);
int age=d1.getYear()-d2.getYear();
System.out.println("Age:" + age);
int x=d2.compareTo(d1); //Big with smaller==> +1 //small with big==> -1
System.out.println(x);
}
}
output:
Current Date:Tue Dec 13 20:45:31 IST 2011
Date of Birth:Tue Jan 01 00:00:00 IST 1985
Age:26
-1
public class DateDemoA
{
public static void main(String args[])
{
Date d1=new Date();
System.out.println("Current Date:" + d1);
Date d2=new Date(84,12,01); //YY,MM,DD
System.out.println("Date of Birth:" + d2);
int age=d1.getYear()-d2.getYear();
System.out.println("Age:" + age);
int x=d2.compareTo(d1); //Big with smaller==> +1 //small with big==> -1
System.out.println(x);
}
}
output:
Current Date:Tue Dec 13 20:45:31 IST 2011
Date of Birth:Tue Jan 01 00:00:00 IST 1985
Age:26
-1
No comments:
Post a Comment