1. Learn
  2. /
  3. Courses
  4. /
  5. Input/Output and Streams in Java

Connected

Exercise

Formatting and parsing dates

Formatting and parsing dates are essential for working with different date representations. In this exercise, you will format a date and parse a string into a LocalDate.

All the required classes from java.time have been imported for you.

Instructions

100 XP
  • Retrieve the current date.
  • Define a DateTimeFormatter with the pattern dd-MM-yyyy.
  • Format the current date using the formatter.
  • Parse a date string using the defined formatter.