java.util.Formatter

This class implements C-style {@code printf()} formatted for text, it is inspired by the C language but it does not match it exactly and this is far more strict in what it requires. Format specifiers start with the {@code '%'} character which defines a sequence accordingly. The format specifiers are in the following format: {@code %[argument_index$][flags][width][.precision]conversion}. Any fields within brackets are optional. For any specifiers which do not conform to arguments, their format is {@code %[flags][width]conversion}. {@code argument_index$} specifies which argument to take the value from, this allows one to use an alternative order. If this is not specified then the order is implied based on the argument order for any specifiers which do not use an argument index. This means that: {@code format("%7$d %d %6$d %d %% %d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)} will print {@code "7 1 6 2 % 3"}. {@code flags} specifies special flags which are used to modify how the printing is done. The following flags are used: - {@code '-'} -- Left justified (general, char, int, float, date). - {@code '#'} -- Conversion dependent alternate form (general, int (only: o, x, X), float). - {@code '+'} -- Include a sign always (int, float). - {@code ' '} -- Include leading space for positive values (int, float). - {@code '0'} -- Zero padding (int, float). - {@code ','} -- Use locale specific grouping separators (int (only: d), float). - {@code '('} -- Negative values are enclosed in parenthesis (int, float). {@code width} is a positive decimal integer which specifies the minimum amount of space the text will take up, it will be aligned accordingly depending on the flags used. {@code precision} is a positive decimal integer which specified a limit on the output, this depends on the format specifier. {@code conversion} is the symbol which determines how the input is to be formatted.