DateTimeFormatter
The java.time class that formats and parses dates and times, from predefined, localized or pattern-based styles.
In more detail
In patterns, case matters: MM is the month and mm the minute, HH the hour of the day and hh the hour of the half day. ofLocalizedDate uses a locale's conventions. A formatter that asks for a field the value lacks, such as an hour from a LocalDate, throws UnsupportedTemporalTypeException.
Example
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")Related terms
- locale — A java.util object naming a language and optionally a country and variant, used to format text, numbers and dates for that audience.
Taught in
- Dates, Times And Daylight Saving — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Locales, Resource Bundles And Formatting — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep