~/ learn/ java-from-zero/ cards/ Formatting & parsing with DateTimeFormatter
1 of 4

Type a DateTimeFormatter and format a date

Type a DateTimeFormatter and format a date

Answer

DateTimeFormatter fmt = DateTimeFormatter.ofPattern("dd/MM/yyyy"); String s = LocalDate.of(2024, 6, 15).format(fmt);

ofPattern creates a reusable formatter. DateTimeFormatter instances are immutable and thread-safe — safe to store in a static field.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/9bf4ac62-e755-4d28-abb4-e97b84c794cb/flashcard utf-8 LF