When a date passes, the system formats it and returns a String with the value of the date. It exist a
correspondence with the standard type of Java java.text.SimpleDateFormat (see the link below).
1 date.format
<date.format
format='format'
lang='lang'
country='country'
timezone='timezone'
type='type'
>
<date /> *
</date.format>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aformat | String | user_format | Date format, for example dd-MM-yyyy HH:mm:ss z. If the format is not indicated, the user's format is used. | ||
Alang | String | user_lang | Language to form the Locale to the parser function. If the format is not indicated, the user's format is used. The language is necessary when the used month's format is alphanumeric (MMM) for example "ene". | ||
Acountry | String | In case the attribute lang is informed, the language of the contry of application can be optionally specified. Differents contries that uses the same language could have differents numerical representations. This code is written in lowercase, with two letters as define the norm ISO-3166. It can be founded a complete list of this codes on several internet sites. | |||
Atimezone | String | Time zone, for example America/Mexico_City. | |||
Atype | String |
This field will only be considered if the format field is not informed. It indicates the standard type of format in which will appear the date. The possible types which will cause a different effect according to the local format defined (by default or the indicated format in the fields lang y country) are:
|
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Edate | date | Date which should be format. |
Returns | |
---|---|
Type | Description |
String | Returns the transformed date. |
Example
Get the current date applying an explicit string formart.
Copy
<xsql-script name='date_format_sample1'> <body> <set name='var'> <date.format format='dd-MM-yyyy'><date.today /></date.format> </set> <println><var /></println> </body> </xsql-script>
Example
Get the current date applying the reoresentation format of user's date.
Copy
<xsql-script name='date_format_sample2'> <body> <set name='userdateformat'><system.user.getDateFormatPattern/></set> <set name='var'> <date.format format='#userdateformat'><date.today /></date.format> </set> <println><var /></println> </body> </xsql-script>
Example
Application of lang and country. Difference between United Kingdom and India for the english.
Copy
<xsql-script name='dateformat_sample3'> <body> <println> <date.format lang='en' country='GB' type='long'> <date.current /> </date.format> <date.format lang='en' country='IN' type='long'> <date.current /> </date.format> </println> </body> </xsql-script>
Example
Comparation between the predefined formats allowed
Copy
<xsql-script name='dateformat_sample4'> <body> <println> <date.format type='short'> <date.current /> </date.format> <date.format type='medium'> <date.current /> </date.format>-> <date.format type='long'> <date.current /> </date.format> </println> </body> </xsql-script>