java.time.format.DateTimeFormatter converts java.time objects such as LocalDate, LocalTime, LocalDateTime and ZonedDateTime to and from text. Unlike the old SimpleDateFormat, it is immutable and thread-safe, so a single formatter can be stored in a static final field and shared. You can call date.format(formatter) or formatter.format(date); both give the same String.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 5 more sections, 5 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.