O'Reilly logo

Beginning Java 8 Fundamentals: Language Syntax, Arrays, Data Types, Objects, and Regular Expressions by Kishori Sharan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required