Java Format Flags

In this chapter you will learn:

  1. What are format flags
  2. Flag List

Description

Flags that controls various aspects of a conversion. All format flags are single characters and follow the % in a format specification.

Flag List

The flags are shown here:

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

Next chapter...

What you will learn in the next chapter:

  1. How to justify Output
  2. Syntax for justify
  3. Example - left-justifies a floating-point number with two decimal places
  4. Example - Use Formatter to left-justify strings within a table
  5. Example - Use Formatter to vertically align numeric values
  6. How to right and left align strings
Home »
  Java Tutorial »
    Java Langauge »
      Java Data Format
Java Formatter Class
Java Format Specifier
Java Format Specifier Uppercase
Java Format Precision
Java Format Flags
Java Format Justifying Output
Java Format Negative and Positive
Java Format Line up Space
Java Format Parentheses
Java Format Zero Padding
Java Format Comma
Java Format Alternate Conversion
Java Format Argument Index
Java Format date time
Java Format Date