Java Format - Java NumberFormat.format(double number)








Syntax

NumberFormat.format(double number) has the following syntax.

public final String format(double number)

Example

In the following code shows how to use NumberFormat.format(double number) method.

/* w  w  w  . j a  va 2 s  .c o m*/
import java.text.NumberFormat;

public class Main {
  public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getPercentInstance();
    System.out.println(numberFormat.format(99.999999));
    
    
  }
}

The code above generates the following result.