Java DecimalFormat .setNegativePrefix (String newValue)

Syntax

DecimalFormat.setNegativePrefix(String newValue) has the following syntax.

public void setNegativePrefix(String newValue)

Example

In the following code shows how to use DecimalFormat.setNegativePrefix(String newValue) method.


import java.text.DecimalFormat;
/*  ww  w. j a v a  2 s . com*/
public class Main {
  public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setNegativePrefix("minus");
    System.out.println(format.format(-123456789.12345678));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat