Pricefx Classic UI is no longer supported. It has been replaced by Pricefx Unity UI.

 

Date, Time and Number Formatting

The following sections are cited from http://www.gwtproject.org/. 

Formatting Date and Time

Patterns (locale-sensitive)

Symbol

Meaning

Presentation

Example

Symbol

Meaning

Presentation

Example

G 

Era designator

Text 

AD

y 

Year

Number

1996

Q 

Quarter

Text 

Q3

L 

Standalone month in year

Text or Nummer 

July or 07

M 

Month in year

Text or Nummer 

July or 07

d 

Day in month

Number

10

h 

Hour in am/pm (1-12)

Number

12

H 

Hour in day (0-23)

Number

0

m 

Minute in hour

Number

30

s 

Second in minute

Number

55

S 

Fractional second

Number

978

E 

Day of week

Text 

Thursday

c 

Standalone day of week

Text 

Thursday

a 

AM/PM marker

Text 

PM

k 

Hour in day (1-24)

Number

24

K 

Hour in am/pm (0-11)

Number

0

z 

Time zone

Text 

UTC-7

Z 

Time zone (RFC 822) 

Text 

-800

v 

Time zone Id 

Text 

Etc/GMT+7

' 

Escape for text

Delimiter

"Date="

'' 

Single quote

Literal

"o'clock"

Number of Pattern Letters

The number of pattern letters influences the format, as follows:

  • Text – If 4 or more, use the full form; if less than 4, use short or abbreviated form if it exists (e.g., "EEEE" produces "Monday", "EEE" produces "Mon")

  • Number – The minimum number of digits. Shorter numbers are zero-padded to this amount (e.g. if "m" produces "6", "mm" produces "06"). Year is handled specially; that is, if the count of 'y' is 2, the year will be truncated to 2 digits. (e.g., if "yyyy" produces "1997", "yy" produces "97".) Unlike other fields, fractional seconds are padded on the right with zero.

  • Text or Number – If 3 or more, use text, otherwise use number. (e.g. "M" produces "1", "MM" produces "01", "MMM" produces "Jan", and "MMMM" produces "January". Some pattern letters also treat a count of 5 specially, meaning a single-letter abbreviation: L, M, E, and c.

Any characters in the pattern that are not in the ranges of ['a '..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', ' .', ' ' (space), '#' and ' @' will appear in the resulting time text even they are not embraced within single quotes.



Time zone handling examples:

Pattern

Example

Pattern

Example

z, zz, zzz

UTC-7

zzzz

UTC-7

Z, ZZ

-700

ZZZ

-07:00

ZZZZ

GMT-07:00

v, vv, vvv, vvvv

Etc/GMT+7



Examples:

Pattern

Formatted Text

Pattern

Formatted Text

yyyy.MM.dd G 'at' HH:mm:ss vvvv

1996.07.10 AD at 15:08:56 America/Los_Angeles

EEE, MMM d, 'yy

Wed, July 10, '96

h:mm a

12:08:00

hh 'o''clock' a, zzzz

12 o'clock PM, Pacific Daylight Time

K:mm a, vvvv

0:00 PM, America/Los_Angeles

yyyyy.MMMMM.dd GGG hh:mm aaa

01996.July.10 AD 12:08 PM

Formatting Numbers

Patterns

Formatting is based on customizable patterns that can include a combination of literal characters and special characters that act as placeholders and are replaced by their localized counterparts. Many characters in a pattern are taken literally; they are unchanged during formatting. Special characters, on the other hand, stand for other characters, strings, or classes of characters. For example, the '#' character is replaced by a localized digit.

Often the replacement character is the same as the pattern character. In the U.S. locale, for example, the ',' grouping character is replaced by the same character ','. However, the replacement is still actually happening, and in a different locale, the grouping character may change to a different character, such as '.'. Some special characters affect the behavior of the formatter by their presence. For example, if the percent character is seen, then the value is multiplied by 100 before being displayed.

The characters listed below are used in patterns. Localized symbols use the corresponding characters taken from corresponding locale symbol collection. To insert a special character in a pattern as a literal (that is, without any special meaning) the character must be quoted. There are some exceptions to this which are noted below.



Symbol 

Location

Localized?

Meaning

Symbol 

Location

Localized?

Meaning

0

Number

Yes

Digit

# 

Number

Yes

Digit, zero shows as absent

Examples of use: 

  • # represents one digit but it is optional, ​so if you format 10.0001 as #'###.## you will end up with 10

  • If you want to force that a certain digit shows up, you use 0 instead of #

    • ​10.001 formatted with 0'000.00 would be displayed as 0'010.00 (just an example)

    • A ​more typical pattern would be #'###.00 -> 10.00
      or

    • #'###.000 -> 10.001

  • If you format 1 with #'###.00 you will end up with 1.00

  • Also, most characters are not interpreted, so if the format string is "Value: #.## USD" and the number is 1.2, the formatting displays "Value: 1.2 USD" (even though a safer way is to write "'Value: '#.##' USD'" because the text between single quotes stay as is – see the last row of this table)

. 

Number

Yes

Decimal separator or monetary decimal separator

- 

Number

Yes

Minus sign

  , 

Number

Yes

Grouping separator

E 

Number

Yes

Separates mantissa and exponent in scientific notation; need not be quoted in prefix or suffix

; 

Subpattern boundary

Yes

Separates positive and negative subpatterns (see details below the table)

   % 

Prefix or Suffix 

Yes

Multiply by 100 and show as percentage

? (\u2030) 

Prefix or Suffix 

Yes

Multiply by 1000 and show as per million

  ¤ (\u00A4) 

Prefix or Suffix 

No

Currency sign, replaced by currency symbol; if doubled, replaced by international currency symbol; if present in a pattern, the monetary decimal separator is used instead of the decimal separator

  '

Prefix or Suffix 

No

Used to quote special characters in a prefix or suffix; for example, "'#'#" formats 123 to "#123"; to create a single quote itself, use two in succession, such as "# o''clock"

If there is a semicolon in the pattern, then the first part (subpattern) is for positive values and the second is for negative ones, e.g. "#,##0.00;(#,##0.00)". Each subpattern has a prefix, a numeric part, and a suffix. If there is no explicit negative subpattern, the negative subpattern is the localized minus sign prefixed to the positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00". If there is an explicit negative subpattern, it serves only to specify the negative prefix and suffix; the number of digits, minimal digits, and other characteristics are ignored in the negative subpattern. That means that "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)".

The prefixes, suffixes, and various symbols used for infinity, digits, thousands separators, decimal separators, etc. may be set to arbitrary values, and they will appear properly during formatting. However, care must be taken that the symbols and strings do not conflict, or parsing will be unreliable. For example, the decimal separator and thousands separator should be distinct characters, or parsing will be impossible.

The grouping separator is a character that separates clusters of integer digits to make large numbers more legible. It commonly used for thousands, but in some locales it separates ten-thousands. The grouping size is the number of digits between the grouping separators, such as 3 for "100,000,000" or 4 for "1 0000 0000".

Pattern Grammar (BNF)

The pattern itself uses the following grammar:

pattern

:=

subpattern (';' subpattern)?

subpattern

:=

prefix? number exponent? suffix?

number

:=

(integer ('.' fraction)?) | sigDigits

prefix

:=

'\u0000'..'\uFFFD' - specialCharacters

suffix

:=

'\u0000'..'\uFFFD' - specialCharacters

integer

:=

'#'* '0'*'0'

fraction

:=

'0'* '#'*

sigDigits

:=

'#'* '@''@'* '#'*

exponent

:=

'E' '+'? '0'* '0'

padSpec

:=

'*' padChar

padChar

:=

'\u0000'..'\uFFFD' - quote



Notation:

X* 

0 or more X symbols

X? 

0 or 1 X symbols

X|Y 

either X or Y

C..F

any symbol from C to F included

S-T 

symbols in S, excluding those in T

The first subpattern is for positive numbers. The second (optional) subpattern is for negative numbers.

Found an issue in documentation? Write to us.

Â