Formatter Format Strings Flashcards
What is Formatter?
An interpreter for printf-style format strings.
What does formatter format option ‘b’, ‘B’ represent?
If the argument arg is null, then the result is “false”. If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(arg). Otherwise, the result is “true”.
What does formatter format option ‘h’, ‘H’ represent?
If the argument arg is null, then the result is “null”. Otherwise, the result is obtained by invoking Integer.toHexString(arg.hashCode())
What does formatter format option ‘s’, ‘S’ represent?
If the argument arg is null, then the result is “null”. If arg implements Formattable, then arg.formatTo is invoked. Otherwise, the result is obtained by invoking arg.toString().
What does formatter format option ‘c’, ‘C’ represent?
The result is a Unicode character
What does formatter format option ‘d’ represent?
The result is formatted as a decimal integer
What does formatter format option ‘o’ represent?
The result is formatted as an octal integer
What does formatter format option ‘x’, ‘X’ represent?
The result is formatted as a hexadecimal integer
What does formatter format option ‘f’ represent?
The result is formatted as a decimal number
What does formatter format option ‘t’, ‘T’ represent?
Prefix for date and time conversion characters. See Date/Time Conversions.
What does formatter format option ‘n’ represent?
The result is the platform-specific line separator.
What does formatter date/time format option ‘M’ represent?
Minute within the hour formatted as two digits with a leading zero as necessary, i.e. 00 - 59.
What does formatter date/time format option ‘S’ represent?
Seconds within the minute, formatted as two digits with a leading zero as necessary, i.e. 00 - 60 (“60” is a special value required to support leap seconds).
What does formatter date/time format option ‘p’ represent?
Locale-specific morning or afternoon marker in lower case, e.g.”am” or “pm”. Use of the conversion prefix ‘T’ forces this output to upper case.
What does formatter date/time format options ‘e’ and ‘m’ represent?
Month. m formats as two digits with leading zeros as necessary, i.e. 01 - 13.