Formatter Format Strings Flashcards

1
Q

What is Formatter?

A

An interpreter for printf-style format strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does formatter format option ‘b’, ‘B’ represent?

A

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”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does formatter format option ‘h’, ‘H’ represent?

A

If the argument arg is null, then the result is “null”. Otherwise, the result is obtained by invoking Integer.toHexString(arg.hashCode())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does formatter format option ‘s’, ‘S’ represent?

A

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().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does formatter format option ‘c’, ‘C’ represent?

A

The result is a Unicode character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does formatter format option ‘d’ represent?

A

The result is formatted as a decimal integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does formatter format option ‘o’ represent?

A

The result is formatted as an octal integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does formatter format option ‘x’, ‘X’ represent?

A

The result is formatted as a hexadecimal integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does formatter format option ‘f’ represent?

A

The result is formatted as a decimal number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does formatter format option ‘t’, ‘T’ represent?

A

Prefix for date and time conversion characters. See Date/Time Conversions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does formatter format option ‘n’ represent?

A

The result is the platform-specific line separator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does formatter date/time format option ‘M’ represent?

A

Minute within the hour formatted as two digits with a leading zero as necessary, i.e. 00 - 59.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does formatter date/time format option ‘S’ represent?

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does formatter date/time format option ‘p’ represent?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does formatter date/time format options ‘e’ and ‘m’ represent?

A

Month. m formats as two digits with leading zeros as necessary, i.e. 01 - 13.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does formatter date/time format option ‘z’ represent?

A

RFC 822 style numeric time zone offset from GMT, e.g. -0800. This value will be adjusted as necessary for Daylight Saving Time. For long, Long, and Date the time zone used is the default time zone for this instance of the Java virtual machine.

17
Q

What does formatter date/time format option ‘Z’ represent?

A

A string representing the abbreviation for the time zone. This value will be adjusted as necessary for Daylight Saving Time. For long, Long, and Date the time zone used is the default time zone for this instance of the Java virtual machine. The Formatter’s locale will supersede the locale of the argument (if any).

18
Q

What does formatter date/time format option ‘B’ represent?

A

Locale-specific full month name, e.g. “January”, “February”.

19
Q

What does formatter date/time format option ‘b’ represent?

A

Locale-specific abbreviated month name, e.g. “Jan”, “Feb”.

Note the ‘h’ format can also be used in place of ‘b’

20
Q

What does formatter date/time format option ‘A’ represent?

A

Locale-specific full name of the day of the week, e.g. “Sunday”, “Monday”

21
Q

What does formatter date/time format option ‘a’ represent?

A

Locale-specific short name of the day of the week, e.g. “Sun”, “Mon”

22
Q

What does formatter date/Time format option ‘C’ represent?

A

Four-digit year divided by 100, formatted as two digits with leading zero as necessary, i.e. 00 - 99

23
Q

What does formatter date/time format option ‘Y’ represent?

A

Year, formatted as at least four digits with leading zeros as necessary, e.g. 0092 equals 92 CE for the Gregorian calendar.

24
Q

What does formatter date/time format option ‘y’ represent?

A

Last two digits of the year, formatted with leading zeros as necessary, i.e. 00 - 99.

25
Q

What does formatter date/time format option ‘j’ represent?

A

Day of year, formatted as three digits with leading zeros as necessary, e.g. 001 - 366 for the Gregorian calendar

26
Q

What does formatter date/time format option ‘d’ represent?

A

Day of month, formatted as two digits with leading zeros as necessary, i.e. 01 - 31

27
Q

What does formatter date/time format option ‘R’ represent?

A

Time formatted for the 24-hour clock as “%tH:%tM”

28
Q

What does formatter date/time format option ‘T’ represent?

A

Time formatted for the 24-hour clock as “%tH:%tM:%tS”.

29
Q

What does formatter date/time format option ‘r’ represent?

A

Time formatted for the 12-hour clock as “%tI:%tM:%tS %Tp”. The location of the morning or afternoon marker (‘%Tp’) may be locale-dependent.