Data Type Formatting Reference
This is a reference page for Date, Number, and String formatting.
Date Format​
Date as a string, formatted according to a pattern. The pattern is a format that is full of various placeholders that will display different parts of the date. These are case-sensitive! These placeholders can be repeated for a different effect. For example, M will give you 1-12, MM will give you 01-12, MMM will give you Jan-Dec, MMMM will give you January-December.
Functions that use this date formatting include:
The table below demonstrate some common formatting elements for convenience. Date formatting in Ignition is largely driven by Java's SimpleDateFormat class. See the SimpleDateFormat documentation for more information.
Symbol | Description | Presentation | Examples | Other Notes |
---|---|---|---|---|
a | Am/Pm marker | Text | PM | |
D | Day in year | Number | 189 | |
d | Day in month | Number | 10 | |
E | Day name in week | Text | EEEE=Tuesday; E=Tue | |
F | Day of week in month | Number | 2 | 2nd Sunday of the month |
G | Era designator | Text | G=AD | |
H | Hour in day (0-23) | Number | 0 | |
h | Hour in am/pm (1-12) | Number | 12 | |
k | Hour in day (1-24) | Number | 24 | |
K | Hour in am/pm (0-11) | Number | 0 | |
M | Month in year | Month | MMMM=July; MMM=Jul; MM=07 | |
m | Minute in hour | Number | 30 | |
s | Second in minute | Number | 55 | |
S | Millisecond | Number | 978 | |
u | Day number of week | Number | 1 | (1 = Monday, ..., 7 = Sunday) |
w | Week in year | Number | 27 | If Dec31 is mid-week, it will be in week 1 of the next year |
W | Week in month | Number | 2 | |
X | Time zone | ISO 8601 time zone | X=-08; XX=-0800; XXX=-08:00 | |
y | Year | Year | yyyy=1996; yy=96 | Lowercase y is the most commonly used year symbol |
Y | Week year | Year | YYYY=2009; YY=09 | Capital Y gives the year based on weeks (ie. changes to the new year up to a week early) |
z | Time zone | General time zone | zzzz=Pacific Standard Time; z=PST | |
Z | Time zone | RFC 822 time zone | Z=-0800 |
Number Format​
Returns a string version of the number argument, formatted as specified by the pattern string. This is commonly used to specify the number of decimal places to display, but can be used for more advanced formatting as well. The pattern string is a numeric format string, which may include any of these characters that instruct it how to format the number.
Functions that use this number formatting include:
The tables below demonstrate some common formatting elements for convenience. Number formatting in Ignition is largely driven by Java's DecimalFormat class. See the DecimalFormat documentation for more information.
Symbol | Description |
---|---|
0 | Specifies a required digit. |
# | Specifies an optional digit. |
, | The grouping separator. |
. | The decimal separator. |
- | A minus sign. |
E | Scientific notation. |
; | Used to separate positive and negative patterns. The negative subpattern will only be used to specify the prefix and suffix. The number of digits, minimal digits, and other characteristics are all the same as the positive pattern. |
% | Multiplies the value by 100 and shows as a percent. |
' | Used to quote special characters. |
Example​
This table shows some numbers, and the result of using various format strings to format them.
Number | Pattern | Result |
---|---|---|
5 | 0 | 5 |
5 | 0.05.0 | |
5 | 00.0 | 05.0 |
123 | #,##0 | 123 |
1024 | #,##0 | 1,024 |
1337 | #,##0.# | 1,337 |
1337.57 | #,##0.# | 1,337.6 |
87.32 | #,##0.0000 | 87.3200 |
-1234 | #,##0 | -1,234 |
-1234 | #,##0;(#) | (1,234) |
4096 | 0.###E0 | 4.096E3 |
.348 | #.00% | 34.80% |
34.8 | #0.00'%' | 34.80% |
String Format​
Functions that use this data formatting include:
Date/Time Formatting Elements​
Date/Time Formatting Element Suffix | Description |
---|---|
H | Hour of the day for the 24-hour clock, formatted as two digits with a leading zero where necessary, i.e., 00 - 23. |
I | Hour of the 12-hour clock, formatted as two digits with a leading zero as necessary, i.e., 01 - 12. |
k | Hour of the day for the 24-hour clock, i.e., 0-24. |
k | Hour of the 12-hour clock, i.e., 1 - 12. |
m | Minute within the hour formatted as two digits with a leading zero where necessary, i.e., 00 - 59. |
S | Seconds within a minute, formatted as two digits with a leading zero where necessary, i.e., 00 - 59. |
L | Millisecond within the second formatted as three digits with leading zeros as necessary, i.e., 000-999. |
B | Locale-specific full month name i.e. "January", "March". |
b | Locale-specific abbreviated month name i.e. "Jan", "Mar". |
A | Full name of the day of the week i.e. "Monday". |
a | Abbreviated name of the day of the week i.e. "Mon". |
Y | Year formatted as a 4 digit numeric value with leading zeros where necessary i.e. 0005 would be the year 5 in the Gregorian calendar. |
y | Last two digits of the year formatted with leading zeros where necessary. |
j | Day of the year formatted as three digits with leading zeros where necessary, i.e., 001 - 366 for the Gregorian calendar. |
M | Month, formatted as a two digit number with leading zeros where necessary, i.e., 01-13. |
d | Day of the month formatted as two digit number with leading zeros where necessary, i.e,. 00 - 31. |
e | Day of the month formatted as two digits, i.e., 0-31. |
Formatting Elements​
Element Character | Data Type to Substitute Element Character | Description |
---|---|---|
b , B | Boolean | If the corresponding argument arg is NULL, then a False is substituted into the format string. If arg is boolean, then the string conversion of arg will be substituted into the format string. For every other condition, True is substituted into the format string. |
s , S | String | The string value arg is substituted into the formatted sting. |
c , C | Character | The unicode value arg is substituted into the formatted string. |
d | Integral | The decimal value arg is substituted into the formatted string. |
f | Floating Point | The floating point value arg is substituted into the formatted string. |
t , T | Date/Time | This is the prefix for date/time arg values to be used for string formatting. |