Formatter Uppercase Option in Java
Description
The following code shows how to formatter Uppercase Option.
Uppercase formatter causes the conversion to use uppercase where appropriate
Specifier | Effect | %A | Causes the hexadecimal digits a through f to be displayed in uppercase as A through F. Also, the prefix 0x is displayed as 0X, and p is displayed as P. | %B | Uppercases the values true and false | %C | Uppercases the corresponding character argument. | %E | Causes the e symbol that indicates the exponent to be displayed in uppercase. | %G | Causes the e symbol that indicates the exponent to be displayed in uppercase. | %H | Causes the hexadecimal digits a through f to be displayed in uppercase as A through F. | %S | Uppercases the corresponding string. | %T | Causes all alphabetical output to be displayed in uppercase. | %X | Causes the hexadecimal digits a through f to be displayed in uppercase as A through F. Also, the optional prefix 0x is displayed as 0X, if present. |
---|
Example
//from ww w. j a v a 2 s . co m
import java.util.Formatter;
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%X", 250);
System.out.println(fmt);
fmt.format("%E", 123.1234);
System.out.println(fmt);
}
}
The code above generates the following result.