Formatting Dates and Times
An object of the DateTimeFormatter class lets you format and parse a datetime object. By formatting, I mean representing a datetime object in a user-defined textual form, for example, representing a LocalDate May 24, 2012 as “05/24/2012.” Sometimes formatting is also referred as printing, because formatting features also let you print (or output) a textual representation of a datetime object to an Appendable object such as a StringBuilder.
Parsing is the reverse of formatting. It lets you construct a datetime object from a textual representation of a datetime. Creating a LocalDate object from the text “05/24/2012” to represent May 24, 2012 is an example of parsing.
Different ways of formatting and parsing datetimes ...