5.11 Formatting Outputs
Again and again, numbers, dates, and text must be formatted in a variety of ways. Java provides various solutions for formatting, such as the following:
-
The format(...) and printf(...) methods enable formatted outputs.
-
Formatting via Format classes: General formatting behavior is fixed in an abstract Format class. Concrete subclasses, such as NumberFormat and DateFormat , take care of specific data formats.
-
Conversion of a string according to a given mask with a MaskFormatter
The Format classes not only provide country- and language-dependent output via format(...), but also the reverse way to split strings back into types like double or date. Any string generated by the Format object can also be read again ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access