com.plumtree.openfoundation.util
Class XPFormat

java.lang.Object
  extended by com.plumtree.openfoundation.util.XPFormat

public final class XPFormat
extends java.lang.Object

XPFormat provides methods for inserting formatted versions of numeric and date values into a format pattern string according to the numeric and date formats of a specified locale or the runtime default. Other objects are inserted in the form derived from toString(). If no locale or a null locale is specified, the runtime default is used to provide a localized format for numeric and date values. Note that the runtime default is not necessarily "en-us", so set an explicit locale value if you need to rely on numeric and date format results.


Constructor Summary
XPFormat()
           
 
Method Summary
static java.lang.String Format(java.lang.String pattern, java.lang.Object[] args)
          Returns pattern with formatted objects.
static java.lang.String Format(XPLocale inLocale, double number)
          Converts a double to its equivalent string representation using the specified locale format information.
static java.lang.String Format(XPLocale inLocale, long number)
          Converts a long to its equivalent string representation using the specified locale format information.
static java.lang.String Format(XPLocale inLocale, java.lang.String pattern, java.lang.Object[] args)
          Returns pattern with formatted objects using the specified locale format information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPFormat

public XPFormat()
Method Detail

Format

public static java.lang.String Format(XPLocale inLocale,
                                      double number)
Converts a double to its equivalent string representation using the specified locale format information.

Parameters:
inLocale - - locale of the current setting, null means the operating system default locale.
number - - number to be formatted
Returns:
a formatted string

Format

public static java.lang.String Format(XPLocale inLocale,
                                      long number)
Converts a long to its equivalent string representation using the specified locale format information.

Parameters:
inLocale - - locale of the current setting. pass in NULL if the default locale is desired
number - - number to be formatted
Returns:
a formatted string

Format

public static java.lang.String Format(java.lang.String pattern,
                                      java.lang.Object[] args)
Returns pattern with formatted objects. Formattable objects include XPDateTime, different types of numeric values and strings. If source contains null objects, the formatted result will substitute each argument with the string "null". Example: Object[] arguments = {new Integer(7), new Date(System.currentTimeMillis()), "a disturbance in the Force"}; String result = MessageFormat.format("At {1}, there was {2} on planet {0}.", arguments); output: At 12:30 PM on Jul 3, 2053, there was a disturbance in the Force on planet 7.

Parameters:
pattern - - string to be formated
args - - expression objs to be formatted, valid objs types include XPDateTime, numeric values and strings
Returns:
a formatted string with formatted objects using the specified locale format
Throws:
XPIllegalArgumentException - - if pattern string is null

Format

public static java.lang.String Format(XPLocale inLocale,
                                      java.lang.String pattern,
                                      java.lang.Object[] args)
Returns pattern with formatted objects using the specified locale format information. Formattable objects include XPDateTime, different types of numeric values and strings. If source contains null objects, the formatted result will substitute each argument with the string "null". If a null locale is passed in, it will use the default locale. Example: Object[] arguments = {new Integer(7), new Date(System.currentTimeMillis()), "a disturbance in the Force"}; String result = MessageFormat.format("At {1}, there was {2} on planet {0}.", arguments); output: At 12:30 PM on Jul 3, 2053, there was a disturbance in the Force on planet 7.

Parameters:
inLocale - - an XPLocale to format the message in, null denotes the runtime default locale which may or may not be en-us.
pattern - - string to be formated
args - - expression objs to be formatted, valid objs types include XPDateTime, numeric values and strings
Returns:
a formatted string with formatted objects using the specified locale format
Throws:
XPIllegalArgumentException - - if pattern string is null


Copyright © 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.