Java Format - Java NumberFormat FRACTION_FIELD








Syntax

NumberFormat.FRACTION_FIELD has the following syntax.

public static final int FRACTION_FIELD

Example

In the following code shows how to use NumberFormat.FRACTION_FIELD field.

import java.text.FieldPosition;
import java.text.NumberFormat;
//  www .  j a va 2 s  .c o m
public class Main {
  public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getPercentInstance();
 
    StringBuffer sb = new StringBuffer();
    
    Object value = 11.111;
    numberFormat.format(value,sb,new FieldPosition(NumberFormat.FRACTION_FIELD));
    System.out.println(sb);
    
  }
}

The code above generates the following result.