Java Format Specifier Uppercase
In this chapter you will learn:
- What is Format Specifier
- How and when to use Uppercase Option for Java Formatter
- How to uppercase hexadecimal
- How to uppercase e symbol
Description
Uppercase versions format specifiers cause the conversion to use uppercase where appropriate.
Uppercase List
Specifier | Effect |
---|---|
%A | Uppercase the hexadecimal digits a through f to A through F. Also, the prefix 0x is displayed as 0X, and the p will be displayed as P. |
%B | Uppercases the values true and false. |
%E | Uppercase the e symbol that indicates the exponent. |
%G | Uppercase the e symbol that indicates the exponent. |
%H | Uppercase the hexadecimal digits a through f to A through F. |
%S | Uppercases the corresponding string. |
%T | Uppercase alphabetical output. |
%X | Uppercase the hexadecimal digits a through f to A through F. Also, the optional prefix 0x is displayed as 0X, if present. |
Example
The following code outputs value in uppercase hexadecimal.
import java.util.Formatter;
/* www. ja va 2 s .c o m*/
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%X", 250);
System.out.println(fmt);
}
}
The output:
Example 2
The following code does uppercase the e
symbol that indicates the exponent
import java.util.Formatter;
// ww w. ja v a 2s . co m
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%E", 123.1234);
System.out.println(fmt);
}
}
Next chapter...
What you will learn in the next chapter:
- How to use precision modifier
- Syntax for Precision Format
- Example - Precision Format
- How to format decimal value in precision
- How to control the number of significant digits for %g
- How to control string length with precision specifier
- Example - Specifying a Minimum Field Width
Java Formatter Class
Java Format Specifier
Java Format Flags
Java Format Justifying Output
Java Format Negative and Positive
Java Format Line up Space
Java Format Parentheses
Java Format Zero Padding
Java Format Comma
Java Format Alternate Conversion
Java Format Argument Index
Java Format date time
Java Format Date
Java Format Specifier
Java Format Specifier Uppercase
Java Format PrecisionJava Format Flags
Java Format Justifying Output
Java Format Negative and Positive
Java Format Line up Space
Java Format Parentheses
Java Format Zero Padding
Java Format Comma
Java Format Alternate Conversion
Java Format Argument Index
Java Format date time
Java Format Date