SilverStream
Application Server 3.5

com.sssw.rt.util
Class AgFormat

java.lang.Object
 |
 +--com.sssw.rt.util.AgFormat

public final class AgFormat
extends Object

The AgFormat class is a helper class for formatting an object as a String. The object can be of numeric type (such as Integer, Long, or Double), or of type java.sql.Date, Time, or Timestamp. For a listing of formatting patterns and styles, see Formatting Patterns and Styles. Also, see the JDK documentation on NumberFormat, DateFormat, DecimalFormat, SimpleDateFormat, and Locale.

Note that the date formatting facility uses a java.sql.Date object, not a java.util.Date. Note also that expontial notation, percent, and per mille are not currently supported for BigDecimals.

The AgFormat.format() methods can be used in the SilverStream Expression Builder.

See Also:
AgParse

Method Summary
static String format(Object ob, String pattern)
          Format an object and produce formatted output string.
static String format(Object ob, String pattern, int style)
          Format an object and produce formatted output string.
static String format(Object ob, String pattern, int timeStyle, int dateStyle)
          Format an object and produce formatted output string.
static String format(Object ob, String pattern, int style1, int style2, Locale locale, String zoneStr)
          Format an object and produce formatted output string.
static String format(Object ob, String pattern, int style1, int style2, String lang, String country, String variant, String zoneStr)
          Format an object and produce formatted output string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

format

public static String format(Object ob,
                            String pattern)
Format an object and produce formatted output string.
Parameters:
ob - specifies the object to be formatted.
pattern - specifies the pattern for the output String. If pattern is null, format() chooses an appropriate format. See Formatting Patterns and Styles.
Returns:
string or null
Usage:

If successful, format() returns the formatted String. If the object is not of one of the allowed types, format() returns a String version of the object. If the object is null, format() returns null.

Note that format() is an overloaded method. Use this version to specify the output pattern or to accept the format() default.

Example:
AgFormat.format(date_col, "yyyy/MM/dd");

format

public static String format(Object ob,
                            String pattern,
                            int style)
Format an object and produce formatted output string.
Parameters:
ob - specifies the object to be formatted.
pattern - specifies the pattern for the output String. If pattern is null, format() uses the style parameter to determine the format of the output String.
style - specifies the style of the output String. See Formatting Patterns and Styles.
Returns:
string or null
Usage:

The pattern parameter overrides the style parameter. If the pattern parameter is null, then the style parameter is used. If successful, format() returns a formatted String. If the object is not of one of the allowed types, format() returns a String version of the object. If the object is null, format() returns null.

Note that format() is an overloaded method. + Use this version to use one of the preformatted styles to format a java.sql.Date, Time, TimeStamp, or numeric object.


format

public static String format(Object ob,
                            String pattern,
                            int timeStyle,
                            int dateStyle)
Format an object and produce formatted output string.
Parameters:
ob - specifies the object to be formatted.
pattern - specifies the pattern for the output String. If pattern is null, format() uses the timeStyle and dateStyle parameters to determine the format of the output String.
timeStyle - specifies the style of the time portion of the output String.
dateStyle - specifies the style of the date portion of the output String. See Formatting Patterns and Styles.
Returns:
string or null
Usage:

The pattern parameter overrides the timeStyle and dateStyle parameters. If the pattern parameter is null, then the style parameters are used. If successful, format() returns the formatted String. If the object is not of one of the allowed types, format() returns a String version of the object. If the object is null, format() returns null.

Note that format() is an overloaded method. Use this version to specify individual preformatted styles for the date and time portions of a TimeStamp object.


format

public static String format(Object ob,
                            String pattern,
                            int style1,
                            int style2,
                            String lang,
                            String country,
                            String variant,
                            String zoneStr)
Format an object and produce formatted output string.
Parameters:
ob - specifies the object to be formatted.
pattern - specifies the pattern for the output String. If pattern is null, format() uses the style1 and style2 parameters to determine the format of the output String.
style1 - specifies the style of the time portion of the output String. A timeStyle can be specified as DEFAULT, SHORT, LONG, or FULL.
style2 - specifies the style of the date portion of the output String. A dateStyle can be specified as DEFAULT, SHORT, LONG, or FULL. See Formatting Patterns and Styles.
lang - specifies the language of the desired Locale. This is the lower-case two-letter codes as defined by ISO-639. These codes should only be used programmatically. You can find a full list of these codes at a number of sites, such as: http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
country - specifies the country of the desired Locale. This is the upper-case two-letter codes defined by ISO-3166. These codes should only be used programmatically. You can find a full list of these codes at a number of sites, such as: http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
variant - specifies the variant of the desired Locale. Defaults to your machine. Variant codes are vendor and browser-specific. For example, the variant code for a Macintosh PC is MAC; for a POSIX machine, the code is POSIX. Enter a null string for this attribute for default behavior.
zoneStr - specifies the timezone. This parameter overrides the default timezone. This parameter applies only to the Timestamp data type. Specify an empty String for any other data type.
Returns:
string or null

format

public static String format(Object ob,
                            String pattern,
                            int style1,
                            int style2,
                            Locale locale,
                            String zoneStr)
Format an object and produce formatted output string.
Parameters:
ob - specifies the object to be formatted.
pattern - specifies the pattern for the output String. If pattern is null, format() uses the style1 and style2 parameters to determine the format of the output String.
style1 - specifies the style of the time portion of the output String. A timeStyle can be specified as DEFAULT, SHORT, LONG, or FULL.
style2 - specifies the style of the date portion of the output String. A dateStyle can be specified as DEFAULT, SHORT, LONG, or FULL. See Formatting Patterns and Styles.
locale - - java.util.locale, overrides default locale
zoneStr - specifies the timezone. This parameter overrides the default timezone. This parameter applies only to the Timestamp data types. Specify an empty String for any other data type.
Returns:
string or null
Usage:
The pattern parameter overrides the style1 and style2 parameters. If the pattern parameter is null, then the styles parameters are used. If successful, format() returns the formatted String. If the object is not of one of the allowed types, format() returns a String version of the object. If the object is null, format() returns null. Note that format() is an overloaded method. Use this version to specify a Locale for the output or to specify a timezone other than the default.

SilverStream
Application Server 3.5