Set minimum field width specifier by applying it to the %f conversion in Java

Description

The following code shows how to set minimum field width specifier by applying it to the %f conversion.

Example


// w  w w .  ja  v a 2 s  .c  o  m
import java.util.Formatter;

public class Main {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();

    fmt.format("|%f|%n|%12f|%n|%012f|", 10.12345, 10.12345, 10.12345);

    System.out.println(fmt);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone