Java Format - Java DecimalFormat .setPositivePrefix (String newValue)








Syntax

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

public void setPositivePrefix(String newValue)

Example

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

// w  w  w .  j av a 2  s.co m
import java.text.DecimalFormat;

public class Main {
  public static void main(String[] argv) throws Exception {
    DecimalFormat format = new DecimalFormat();
    format.setPositivePrefix("Positive");
    System.out.println(format.format(123456789.12345678));

  }
}

The code above generates the following result.