< Prev
Next >



Calendar Class







import java.util.*;
class A
{
public static void main(String... ar)
{
Date d= new Date(1000000000000l);
System.out.println("Date object" + d);

Calendar c = Calendar.getInstance();
c.setTime(d);
System.out.println("Calendar object initialized to Date object: ")
System.out.println("DATE : "+ c.get(Calendar.DATE));
System.out.println("MONTH : "+c.get(Calendar.MONTH));
System.out.println("YEAR : "+ c.get(Calendar.YEAR));
System.out.println("HOUR : "+ c.get(Calendar.HOUR));
System.out.println("MINUTE : "+ c.get(Calendar.MINUTE));
System.out.println("SECOND : "+ c.get(Calendar.SECOND));
}
}


Output -


Date object : Sun Sep 09 07:16:40 IST 2001
Calendar Object:
DATE : 9
MONTH : 8
YEAR : 2001
HOUR : 7
MINUTE : 16
SECOND : 40





Please share this article -

Facebook Google Pinterest Reddit Tumblr Twitter



< Prev
Next >
< Date class
GregorianCalendar class >
Please subscribe our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next
-
C++ and Python

Ad2