58. Date class in java
//java.util.Date class
import java.util.*;
class java_Date_class
{
public static void main(String[] args) {
Date d = new Date();
System.out.println(d);
System.out.println("Year : " + (d.getYear() + 1900));
System.out.println("Month : " + d.getMonth());
System.out.println("Date : " + d.getDate());
Date birthdate = new Date(121, 02, 15);
System.out.println("d.after(birthdate) : " + d.after(birthdate));
System.out.println("d.before(birthdate) : " + d.before(birthdate));
System.out.println("d.equals(birthdate) : " + d.equals(birthdate));
}
}
OUTPUT:
Mon Feb 15 21:56:57 IST 2021
Year : 2021
Month : 1
Date : 15
d.after(birthdate) : false
d.before(birthdate) : true
d.equals(birthdate) : false
Comments
Post a Comment