Skip to content

Commit f213ac0

Browse files
committed
feat(datetime-api): add DateTimeDemo showcasing legacy java.util.Date usage
What - Introduced `DateTimeDemo` class to demonstrate various ways of working with `java.util.Date`. - Covers: - `new Date()` → fetches current system date and time. - `new Date(System.currentTimeMillis())` → constructs a Date from epoch-based timestamp. - `new Date("1/1/1990")` → deprecated string constructor (parses into a Date object). - `getTime()` → retrieves milliseconds since epoch (Jan 1, 1970). - `getDay()`, `getMonth()`, and `getDate()` → extracts components of the date (day of week, month index, and day of month). Why - Provides hands-on examples of the old `java.util.Date` API. - Useful for understanding how legacy codebases manage dates. - Highlights deprecated constructors and methods, motivating migration to `java.time` API. How to use - Run `DateTimeDemo` to print: - Current date/time. - Custom epoch-based date. - Parsed historical date. - Millisecond timestamp. - Day, month, and date values. Real-life applications - Reading/modifying legacy code where `java.util.Date` is still in use. - Debugging date-related issues in pre-Java 8 applications. - Interfacing with old libraries or databases that return `Date` objects. Notes - Many `java.util.Date` constructors and methods (e.g., `Date(String)`, `getDay()`, `getMonth()`) are deprecated. - Prefer modern `java.time` classes (`LocalDate`, `LocalDateTime`, `ZonedDateTime`) for new projects. Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent faadedb commit f213ac0

File tree

1 file changed

+0
-0
lines changed

1 file changed

+0
-0
lines changed

0 commit comments

Comments
 (0)