Skip to content

Commit be989a2

Browse files
committed
feat(datetime): add CalendarDemo using GregorianCalendar
What - Implemented CalendarDemo class to demonstrate usage of java.util.GregorianCalendar. - Showcased methods for: • Checking leap year with isLeapYear(). • Getting current date, month, day of week, and day of month. • Printing full calendar object details. Why - Demonstrates how the legacy Calendar API works in real-world scenarios. - Useful for understanding date and time handling in pre–Java 8 applications. - Highlights GregorianCalendar as the commonly used calendar system (worldwide standard). Notes - Calendar.DATE → current day of the month. - Calendar.MONTH → zero-based index (January = 0). - Calendar.DAY_OF_WEEK → values 1–7 (Sunday = 1). - Calendar.DAY_OF_MONTH → same as DATE but explicitly named. - isLeapYear(year) → checks if the given year is a leap year. Next Steps - Add examples of manipulating dates (add/subtract days, months). - Compare with java.time.LocalDate for modern, immutable, and thread-safe usage. Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 830ea92 commit be989a2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Section26DateandTimeAPI/src/CalendarDemo.java renamed to Section26DateandTimeAPI/Calendar/src/CalendarDemo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
public class CalendarDemo {
55
public static void main(String[] args) {
66
//Gregorian Calendar we follow.
7-
87
GregorianCalendar gc = new GregorianCalendar();
8+
99
System.out.println(gc.isLeapYear(2020));
1010

1111
System.out.println("Today Date: "+gc.get(Calendar.DATE));
@@ -16,4 +16,4 @@ public static void main(String[] args) {
1616

1717
System.out.println(gc);
1818
}
19-
}
19+
}

0 commit comments

Comments
 (0)