Using the Format Flags : Formatter Flags « Development « Java Tutorial

Formatter uses a set of format flags to control various aspects of a conversion.

A format flag follows the % in a format specification.

-Left justification
#Alternate conversion format
0Output is padded with zeros rather than spaces
spacePositive numeric output is preceded by a space
+Positive numeric output is preceded by a + sign
,Numeric values include grouping separators
(Negative numeric values are enclosed within parentheses

6.6.Formatter Flags
6.6.1.Using the Format Flags
6.6.2.The %n inserts a newline: the %n and %% format specifiers
6.6.3.Left justification
6.6.4.The Space, +, 0, and '(' Flags: To show a '+' sign before positive numeric values, add the + flag
6.6.5.Demonstrating the space format specifiers
6.6.6.To show negative numeric output inside parentheses, rather than with a leading -, use the '(' flag
6.6.7.The 0 flag
6.6.8.The Comma Flag(,) : to add grouping specifiers
6.6.9.The # Flag
6.6.10.format: %#x
6.6.11.format: %#o
6.6.12.Demonstrate the %g format specifier.