Uppercase Option

In this chapter you will learn:

  1. How and when to use Uppercase Option for Java Formatter
  2. How to uppercase hexadecimal
  3. How to uppercase e symbol

Uppercase Option and its effects

Uppercase versions format specifiers cause the conversion to use uppercase where appropriate.

SpecifierEffect
%AUppercase 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.
%BUppercases the values true and false.
%EUppercase the e symbol that indicates the exponent.
%GUppercase the e symbol that indicates the exponent.
%HUppercase the hexadecimal digits a through f to A through F.
%SUppercases the corresponding string.
%TUppercase alphabetical output.
%XUppercase the hexadecimal digits a through f to A through F. Also, the optional prefix 0x is displayed as 0X, if present.

uppercase hexadecimal

The following code outputs value in uppercase hexadecimal.

import java.util.Formatter;
/*from j  a v  a2s .  co  m*/
public class Main {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("%X", 250); 
    System.out.println(fmt);
  }
}

The output:

uppercase e symbol

The following code does uppercase the e symbol that indicates the exponent

import java.util.Formatter;
/*  j a  v a2  s  .  c  o  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:

  1. Using an Argument Index
  2. How to reuse the parameter
  3. How to use relative index
  4. How to use relative index to create customized date format
Home » Java Tutorial » String

String

    Java String type
    Java String Concatenation
    Java String Creation
    Java String Compare
    Java String Search
    Java String and char array
    Java String Conversion
    String trim, length, is empty, and substring
    String replace

StringBuffer

    StringBuffer class
    StringBuffer Insert and Append
    StringBuffer length and capacity
    StringBuffer char operation
    StringBuffer Operations
    Search within StringBuffer
    StringBuffer to String

StringBuilder

    StringBuilder
    StringBuilder insert and append
    StringBuilder length and capacity
    StringBuilder get,delete,set char
    StringBuilder delete, reverse
    StringBuilder search with indexOf and lastIndexOf
    StringBuilder to String

String Format

    Formatter class
    Format Specifier
    Format String and characters
    Format integer value
    Format decimal
    Scientific notation format
    Format octal and hexadecimal value
    Format date and time value
    Escape Formatter
    Minimum Field Width
    Specifying Precision
    Format Flags
    Uppercase Option
    Formatter Argument Index
    Align left and right
    Left and right padding a string

String Format Utilities

    Abbreviate string
    Caplitalize a string
    Uncapitalize a string
    Utility class for right padding
    Left padding
    Centers a String
    Transforms words