Java Format Parentheses

Description

( gives negative numeric values parentheses.

Syntax

fmt.format("%(d", -100);

Example

The ( flag shows negative numeric inside parentheses, rather than with a leading -.


import java.util.Formatter;
/*from www  .  java  2s . com*/
public class Main {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("%(d", -100);
    System.out.println(fmt);
  }
}

The output:





















Home »
  Java Tutorial »
    Data Format »




Java Formatter
Java Number Formatter