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

Taught in

References

Certification courses