Commit be989a2
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
1 file changed
+2
-2
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
0 commit comments