Formatter: format('%.15s', String str) (Display at most 15 characters in a string) : Formatter « java.util « Java by API Java by API java.util Formatter Formatter: format('%.15s', String str) (Display at most 15 characters in a string)
/*
Formatting with
*/
import java.util.Formatter;
public class MainClass {
public static void main(String args[]) {
Formatter fmt = new Formatter();
// Display at most 15 characters in a string.
fmt = new Formatter();
fmt.format("%.15s" , "Formatting with Java is now easy." );
System.out.println(fmt);
}
}
Related examples in the same category 1. new Formatter(Appendable a) 2. Formatter: format('%.4f', 123.1234567) (Format 4 decimal places) 3. Formatter: format('%4d %4d %4d', 1, 2, 3) 4. Formatter: format('%16.2e', 123.1234567) (Format to 2 decimal places in a 16 character field) 5. Formatter: format('|%10.2f|', 123.123) (Right justify by default) 6. Formatter: format('|%f|%n|%12f|%n|%012f|', 10.12345, 10.12345, 10.12345) (a field-width specifier) 7. Formatter: format('|%-10.2f|', 123.123) ( left justify ) 8. Formatter: format('% d', -100) (the space format specifiers) 9. Formatter: format('%g', i) 10. Formatter: format('%n %d%% ', 88) (the %n and %% format specifiers) 11. Formatter: format('%tB %tb %tm', cal, cal, cal) (Display month by name and number) 12. Formatter: format('%tc', cal) (Display complete time and date information) 13. Formatter: format('%te of % < tB, % < tY', cal) 14. Formatter: format('%tl:%tM', cal, cal) (Display just hour and minute) 15. Formatter: format('%tr', cal) (Display standard 12-hour time format) 16. Formatter: format(String format, Object... args)