You are viewing the documentation for Blueriq 14. Documentation for other versions is available in our documentation directory.
TSL format
There are two different types of formatting available in TSL, number formats and date formats. Both formats are applied to attributes or expressions in the same way.
Syntax
[[[expression{format}]]]
Inputs
expression: is a number or date
format: is the number or date formatting
Numbers
In TSL, you can use number formats to change the appearance of numbers, without changing the number behind the appearance. The number format you apply does not affect the actual value. In this context a number can be any of the following basetypes; number, integer, currency or percentage.
The number formats used in TSL are common Java decimal formats. The most commonly used formatting symbols are listed below. For a complete documentation we refer to the online java documentation that is available at https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/DecimalFormat.html.
Symbol | Name | Meaning |
---|---|---|
0 | Digit_zero | displays insignificant zeros if a number has fewer digits than there are zeros in the format |
# | Digit | displays only significant digits and does not display insignificant zeros |
, | Thousand separator | The integer portion of a number is often split into groups by a grouping separator. Western numbers generally separate numbers into thousands, or groups of 3 digits. However, other styles exist. |
. | Decimal separator | The separator between integer and fractional parts of a number |
- | Minus sign | Sign to specify a negative value |
; | Sub pattern separator | Separates formatting for positive and negative numbers |
% | Percentage sign | Multiply by 100 and show as percentage |
¤(ALT_0164) | Currency sign | Use localized currency symbol (for € sign simply use ALT_0128) |
‘ | Escape character | Use special characters as ordinary characters |
These symbols are used to create a format pattern. How this pattern is created is shown in the examples below.
To use the symbols as ordinary characters in your expression use the escape character.
Note that the formatting depends on the language that is used. This means that when you specify a thousand separator ,
in the Dutch language this is outputted as a .
Examples
Format pattern | Number | Result (with English language) | Result (with Dutch language) |
---|---|---|---|
{0000000000} | 9813756.198 | 0009813756 | 0009813756 |
{##########} | 9813756.198 | 9813756 | 9813756 |
{#,###.##} | 9813756.198 | 9,813,756.2 | 9.813.756,2 |
{#,-##0.00} | -9813756.198 | 9,813,756.20- | 9.813.756,20- |
{-#,##0.00} | 9813756.198 | -9,813,756.20 | -9.813.756,20 |
{#,##0.00;-#,##0.00} | 9813756.198 | 9,813,756.20 | 9.813.756,20 |
{#,##0.00;-#,##0.00} | -9813756.198 | -9,813,756.20 | -9.813.756,20 |
{#,##0.## %} | 0.8 | 80 % | 80 % |
{% #,##0.##} | 0.8 | % 80 | % 80 |
{¤ #,##0.00} | 9813756.198 | £ 9,813,756.20 | € 9.813.756,20 |
{#,##0.00 ¤} | 9813756.198 | 9,813,756.20 £ | 9.813.756,20 € |
{#,##0.00 €} | 9813756.198 | 9,813,756.20 € | 9.813.756,20 € |
{€ #,##0.00} | 9813756.198 | € 9,813,756.20 | € 9.813.756,20 |
{‘#’#} | 123 | #123 | #123 |
Dates
In TSL, you can use date formats to change the appearance of dates, without changing the date behind the appearance. The date format you apply does not affect the actual value.
Date pattern | Description |
---|---|
d | Displays the day as a number without a leading zero. |
dd | Displays the day as a number with a leading zero when appropriate. |
M | Displays the month as a number without a leading zero. |
MM | Displays the month as a number with a leading zero when appropriate. |
yy | Displays the year as a two-digit number. |
yyyy | Displays the year as a four-digit number. |
h | Displays the hour as a number without a leading zero, based on the 12-hour clock. |
HH | Displays the hour as a number with a leading zero, based on the 24-hour clock. |
hh | Displays the hour as a number with a leading zero, based on the 12-hour clock. |
mm | Displays the minute as a number with a leading zero. |
ss | Displays the second as a number with a leading zero. |
S | Displays the decisecond |
SS | Displays the centisecond |
SSS | Displays the millisecond |
a | Displays AM for times from midnight until noon and PM for times from noon until midnight. |
The following characters are allowed to be used as separators in a date pattern:
Character | Description |
---|---|
- | Hyphen |
, | Comma |
. | Period |
; | Semicolon |
: | Colon |
Space | |
/ | Forward slash |
T | Time separator |
These symbols are used to create a format pattern.
Examples
Format pattern | Example result |
---|---|
TODAY{dd-MM-yyyy} | 11-04-2019 |
NOW{dd-MM-yyyyTHH:mm:ss.SSS} | 11-04-2019T11:06:56.330 |
NOW{hh:mm a} | 09:40 AM |