Docs‎ > ‎Reference‎ > ‎

Data formatting

In some rules, you can use formatting string to format numbers and dates. This page describes the syntax for these format string.

Numbers

Numbers can be formatted using a pattern string, which can be composed of two parts: one for positive values, the other for negative values.
The pattern string can contain the following symbols:

 Symbol Meaning
 0 Digit, leading or trailing zero shows as zero
 # Digit, leading or trailing zero shows as absent
 . Decimal separator
 - Minus sign (shown only if number is negative)
 , Grouping separator
 E Separates mantissa and exponent in scientific notation
 ; Separates positive and negative subpatterns
 % Multiply by 100 and show as a percentage
 ' Used to quote special characters

Any character not in this list can be used in the string, and will be shown as is. If you need to show a special character as is, without it being interpreted, you'll need to put it in single quotes.

Examples

 Value Format string
 Result
 12 # 12
 12.1 000.00 012.10
 12345.678 #,##0.0 12,345.7
 0.643 % 64.3%
 -12.3 0.00;(0.00) (12.30)
 12.3 '#'0.00 #12.30


Dates

Dates (and timestamps) can be formatted using the following characters:

 Symbol Meaning Examples
 G Era designator
 G -> AD
 y Year yy -> 13  yyyy -> 2013
 M Month in year
 MM -> 03  MMM -> Mar   MMMM -> March
 w Week in year
 w -> 13
 W Week in month
 W -> 3
 D Day in year
 D -> 127
 d Day in month
 d -> 28
 F Day of week
 F -> 6
 E Name of day in week
 E -> Mon  EEEE -> Monday
 a AM/PM a -> PM
 H Hour in day (0-23)
 H -> 7  HH -> 07
 k Hour in day (1-24)
 k -> 8  kk -> 08
 K Hour in AM/PM (0-11)
 K -> 7  KK -> 07
 h Hour in AM/PM (1-12)
 h -> 8  hh -> 08
 m Minute in hour (0-59)
 m -> 6  mm -> 06
 s Second in minute (0-59)
 s -> 4  ss -> 04
 S Milliseconds (0-999)
 S -> 385
 z Time zone
 z -> GMT-08:00  zzz -> PST  zzzz -> Pacific Standard Time
 Z Time zone in RFC 822 format
 Z -> -0800