Formatting patterns and styles are special characters used to format a Java object as a String. This chapter describes how to use formatting patterns and styles in SilverStream. It is organized as follows:
In SilverStream you can an use formatting patterns and styles in the following contexts:
Formatting patterns and styles can be used with the various versions of AgFormat.format(), and are based on Java standards.
For more information, see the on-line help page for AgFormat.
Formatting patterns and styles can also be used in the SilverStream Expression Editor with the format() and parse() functions.
For information about SilverStream expressions, see Expressions, Operators, and Built-in Functions.
Page and Form Designers
Formatting patterns and styles in the Property Inspector for controls that display numeric and date data. You can specify the patterns or select styles from a drop-down list in the Display Format property.
Both the format and parse functions use dates and times in a locale-specific way. For dates and timestamps that occur prior to 1970, you must be sure to enter the value using the ANSI SQL standard format, which is YYYY-MM-DD HH:MM:SS. You can include a nanosecond value using the .FFFF format, but it is optional. Date and time patterns are made up of the following characters (case is important).
Month in year as number with no leading 0. MM displays the month with a leading 0 if it is less than 10 (i.e., 09). MMM displays the three letter abbreviation of the month (SEP). MMMM displays the full name of the month.
The number of pattern letters determines the format, as described below.
When working with text
for four or more characters, JDK uses the FULL style. For less than four characters JDK uses the SHORT style. (For examples of the FULL and SHORT styles see the section on "Time and timestamp values").
When working with numbers
JDK uses the minimum number of digits. Shorter numbers are zero-padded to this amount. This is true for all numbers except year numbers which are handled differently. If the number of pattern characters in a year is 2, the year is truncated to 2 digits.
When working with numbers and text
JDK assumes it is text if there are three or more pattern characters, otherwise it is displayed as a number.
Any pattern characters that are not in the ranges of ['a'..'z'] and ['A'..'Z'] are treated as quoted text. For example, characters: colon (:) , period (.),and pound sign appear in the time text even though they are not enclosed in single quotes.
This table shows typical formats for dates, times, and timestamps.
The following table shows examples of using built-in patterns to specify format styles for dates and times. The column labeled Style represents the style name that appears in the SilverStream Designer property sheet.
NOTE The Style name cannot be used when writing expressions in the Expression Editor. When specifying a style name in the Programming Editor, prepend the class name to the style name. For example:
You can create numeric patterns using a string of the characters listed in the following table.
Numeric objects can be specified as one of the formats shown in the following table. The results shown in the following table were computed using 200.5 as the input.
NOTE The Style name name cannot be used when writing expressions in the Expression Editor: You must specify the pattern. When specifying a style name in the Programming Editor, prepend the class name to the style name. For example: