Java Format Comma

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  ww .ja  va 2s  . c  o m*/
public class Main {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("%,.2f", 1234567890.34); 
    System.out.println(fmt);
  }
}

The output:





















Home »
  Java Tutorial »
    Data Format »




Java Formatter
Java Number Formatter