Formatter « java.util « Java by API






1.new Formatter(Appendable a)
2.Formatter: format('%.15s', String str) (Display at most 15 characters in a string)
3.Formatter: format('%.4f', 123.1234567) (Format 4 decimal places)
4.Formatter: format('%4d %4d %4d', 1, 2, 3)
5.Formatter: format('%16.2e', 123.1234567) (Format to 2 decimal places in a 16 character field)
6.Formatter: format('|%10.2f|', 123.123) (Right justify by default)
7.Formatter: format('|%f|%n|%12f|%n|%012f|', 10.12345, 10.12345, 10.12345) (a field-width specifier)
8.Formatter: format('|%-10.2f|', 123.123) ( left justify )
9.Formatter: format('% d', -100) (the space format specifiers)








10.Formatter: format('%g', i)
11.Formatter: format('%n %d%% ', 88) (the %n and %% format specifiers)
12.Formatter: format('%tB %tb %tm', cal, cal, cal) (Display month by name and number)
13.Formatter: format('%tc', cal) (Display complete time and date information)
14.Formatter: format('%te of % < tB, % < tY', cal)
15.Formatter: format('%tl:%tM', cal, cal) (Display just hour and minute)
16.Formatter: format('%tr', cal) (Display standard 12-hour time format)
17.Formatter: format(String format, Object... args)