sample code to demonstrate Date class
// simple Date application
package collection;
import java.util.Date;
public class MyDate {
public static void main(String[] args)
{
Date d=new Date(2000,4,15);
System.out.println(d);
long sec=d.getTime();
// System.out.println(sec);
String str=d.toString();
System.out.println(str);
if((new Date(1999,5,15)).equals(new Date(2000,5,15)))
System.out.println("Equals");
else
System.out.println("Not Equals");
}
}
Output:
Tue May 15 00:00:00 IST 3900
Tue May 15 00:00:00 IST 3900
Not Equals
0 comments:
Post a Comment