Format number to use percentage in Java
Description
The following code shows how to format number to use percentage.
Example
//from w w w.jav a 2 s . co m
import java.text.DecimalFormat;
public class Main {
public static void main(String[] argv) throws Exception {
DecimalFormat df = new DecimalFormat("#%");
System.out.println(df.format(0.19));
System.out.println(df.format(-0.19));
}
}
The code above generates the following result.