Samples JDK
Sample.java
1 package com.freemindcafe.format.sample1;
2 
3 import org.junit.Test;
4 
5 public class Sample {
6 
7  @Test
8  public void test1(){
9 
10  //Controlling integer width with printf
11  System.out.printf("%3d%n", 0);
12  System.out.printf("%3d%n", 123456789);
13  System.out.printf("%3d%n", -10);
14  System.out.printf("%3d%n", -123456789);
15 
16  //Left-justifying printf integer output
17  System.out.printf("%-3d%n", 0);
18  System.out.printf("%-3d%n", 123456789);
19  System.out.printf("%-3d%n", -10);
20  System.out.printf("%-3d%n", -123456789);
21 
22  //The printf zero-fill option
23 
24  }
25 
26 }