Java Format Comma
In this chapter you will learn:
- What is grouping separators
- Syntax for grouping separators
- How to add grouping specifiers for large value numbers
Description
, adds grouping separators to numeric values.
Syntax
fmt.format("%,.2f", 1234567890.34);
Example
The comma (,) flag adds grouping specifiers.
import java.util.Formatter;
//from w w w . j av a 2 s . c om
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%,.2f", 1234567890.34);
System.out.println(fmt);
}
}
The output:
Next chapter...
What you will learn in the next chapter:
- What is Java Format Alternate Conversion
- Syntax for Java Format Alternate Conversion
- Example - Java Format Alternate Conversion
- Example - the hexadecimal number
- Example - the octal number
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 Argument Index
Java Format date time
Java Format Date
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 ConversionJava Format Argument Index
Java Format date time
Java Format Date