Java Tutorial/Development/Formatter Uppercase Option

Материал из Java эксперт
Версия от 15:29, 31 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

format: uppercase E

import java.util.Formatter;
public class MainClass {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("%E", 123.1234);
    System.out.println(fmt);
  }
}



1.231234E+02


format: uppercase X

import java.util.Formatter;
public class MainClass {
  public static void main(String args[]) {
    Formatter fmt = new Formatter();
    fmt.format("%X", 250);
    System.out.println(fmt);
  }
}



FA


The Uppercase Option

uppercase formatter causes the conversion to use uppercase where appropriate

SpecifierEffect%ACauses 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.%BUppercases the values true and false%CUppercases the corresponding character argument.%ECauses the e symbol that indicates the exponent to be displayed in uppercase.%GCauses the e symbol that indicates the exponent to be displayed in uppercase.%HCauses the hexadecimal digits a through f to be displayed in uppercase as A through F.%SUppercases the corresponding string.%TCauses all alphabetical output to be displayed in uppercase.%XCauses 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.