Argument Index

Java-Argument Index

Argument Index Formatter includes a very useful feature that lets you specify the argument to which a format specifier applies. Normally, format specifiers and arguments are matched in order, from left to right. That is, the first format specifier matches the first argument, the second format specifier matches the second argument, and so on. However, … Read more…

Format Flags

Java-Format Flags

Format Flags Formatter recognizes a set of format flags that lets you control various aspects of a conversion. All format flags are single characters, and a format flag follows the % in a format specification. Some of those: Left justification By default, all output is right-justified. That is, if the field width is larger than … Read more…

Precision Specifier

Java-Precision Specifier

Precision Specifier A precision specifier can be applied to the %f, %e, %g, and %s format specifiers, among others. It follows the minimum field-width specifier (if there is one) and consists of a period followed by an integer. Its exact meaning depends upon the type of data to which it is applied. When you apply … Read more…

Minimum Field Width Specifier

Java-Minimum Field Width Specifier

Minimum Field Width Specifier An integer placed between the % sign and the format conversion code acts as a minimum field-width specifier. This pads the output with spaces to ensure that it reaches a certain minimum length. If the string or number is longer than that minimum, it will still be printed in full. For … Read more…

Formatting Time and Date

Java-Formatting Time and Date

Formatting Time and Date The conversion specifier %t is used to format time and date information. The %t specifier works a bit differently than the others because it requires the use of a suffix to describe the portion and precise format of the time or date desired. For example, to display time, you would use … Read more…

Formatter

Java-Formatter

Formatter Formatter class is used to creating formatted output. It provides format conversions that let you display numbers, strings, and time and date in virtually any format you like. It operates in a manner similar to the C/C++ printf( ) function, which means that if you are familiar with C/C++, then learning to use Formatter … Read more…