-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalenderClass.java
More file actions
19 lines (17 loc) · 1012 Bytes
/
CalenderClass.java
File metadata and controls
19 lines (17 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//* We are exploring the Calender Class
//* The calendar class in java provides the methods that helps in converting date between a specific instant in time */
import java.util.Calendar;
public class CalenderClass {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
System.out.println(c.getCalendarType()); // Give the type of calender type (ex., gregorian)
System.out.println(c.getTimeZone()); // Print the Time Zone
System.out.println(c.getFirstDayOfWeek()); // Output: 1 (Monday)
System.out.println("Current year is :" + c.get(Calendar.YEAR));
System.out.println("Current month is :" + c.get(Calendar.MONTH));
System.out.println("Current day is :" + c.get(Calendar.DAY_OF_WEEK));
System.out.println("Current hour is :" + c.get(Calendar.HOUR_OF_DAY));
System.out.println("Current minute is :" + c.get(Calendar.MINUTE));
System.out.println("Current second is :" + c.get(Calendar.SECOND));
}
}