FileDocCategorySizeDatePackage
Formatter.javaAPI DocphoneME MR2 API (J2ME)5866Fri May 04 08:29:12 BST 2007javax.microedition.global

Formatter

public final class Formatter extends Object

Fields Summary
public static final int
TIME_LONG
public static final int
TIME_SHORT
public static final int
DATE_LONG
public static final int
DATE_SHORT
public static final int
DATETIME_LONG
public static final int
DATETIME_SHORT
private String
locale
Current Formatter locale.
private static com.sun.j2me.global.FormatAbstractionLayer
formatAbstractionLayer
FormatAbstractionLayer subclass instance for obtaining of Formatter realization.
private com.sun.j2me.global.CommonFormatter
formatterImpl
Current Formatter realization instance.
Constructors Summary
public Formatter()


    // JAVADOC COMMENT ELIDED 
        
        this(System.getProperty("microedition.locale"));
    
public Formatter(String locale)

        if (!LocaleHelpers.isValidLocale(locale) && !("".equals(locale))) {
            throw new IllegalArgumentException("Invalid locale format");
        }

        locale = LocaleHelpers.normalizeLocale(locale);

        if ("".equals(locale)) {
            this.locale = null;
        } else {
            this.locale = locale;
        }

        if (this.locale == null) {
            formatterImpl = FormatAbstractionLayer.getNeutralFormatter();
        } else {
            formatterImpl = formatAbstractionLayer.getFormatter(locale);
        }
    
Methods Summary
public java.lang.StringformatCurrency(double number)

        return formatterImpl.formatCurrency(number);
    
public java.lang.StringformatCurrency(double number, java.lang.String currencyCode)


        if (currencyCode.length() != 3 ||
            currencyCode.charAt(0) < 'A" || currencyCode.charAt(0) > 'Z" ||
            currencyCode.charAt(1) < 'A" || currencyCode.charAt(1) > 'Z" ||
            currencyCode.charAt(2) < 'A" || currencyCode.charAt(2) > 'Z") {
            throw new IllegalArgumentException("Illegal currency code");
        }

        return formatterImpl.formatCurrency(number, currencyCode);
    
public java.lang.StringformatDateTime(java.util.Calendar dateTime, int style)

        if (dateTime == null) {
            throw new NullPointerException("Calendar is null.");
        }
        if (style < DATE_SHORT || style > DATETIME_LONG) {
            throw new IllegalArgumentException("Illegal style value");
        }

        return formatterImpl.formatDateTime(dateTime, style);
    
public static java.lang.StringformatMessage(java.lang.String template, java.lang.String[] params)

    	if (template == null || params == null) {
    		throw new NullPointerException("Template or parameter array is null.");
    	}	    	
    	return MessageFormat.format(template, params);
    
public java.lang.StringformatNumber(double number)

        return formatterImpl.formatNumber(number);
    
public java.lang.StringformatNumber(double number, int decimals)


        if (decimals < 1 || decimals > 15) {
            throw new IllegalArgumentException("Illegal number of decimals");
        }

        return formatterImpl.formatNumber(number, decimals);
    
public java.lang.StringformatNumber(long number)

        return formatterImpl.formatNumber(number);
    
public java.lang.StringformatPercentage(long number)

        return formatterImpl.formatPercentage(number);
    
public java.lang.StringformatPercentage(float number, int decimals)


        if (decimals < 1 || decimals > 15) {
            throw new IllegalArgumentException("Illegal number of decimals");
        }

        return formatterImpl.formatPercentage(number, decimals);
    
public java.lang.StringgetLocale()

        return locale;
    
public static java.lang.String[]getSupportedLocales()

        return formatAbstractionLayer.getSupportedLocales();