Use ; symbol to specify an alternate pattern for negative values in Java
Description
The following code shows how to use ; symbol to specify an alternate pattern for negative values.
Example
/* w w w .j av a2s . com*/
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class Main{
public static void main(String[] argv) throws Exception{
NumberFormat formatter = new DecimalFormat("#;(#)");
String s = formatter.format(-1234.567); // (1235)
System.out.println(s);
}
}
The code above generates the following result.