|
Function | Description | |
---|---|---|
| Converts the passed
| |
LocalDate date(Partial value) | Converts the passed Partial
| |
LocalDate date(long value) | Converts the passed timestamp
| |
LocalDate date(long value, String timezone) | Same as date(long value) but with timezone. Valid timezone IDs are: 1. offset, e.g. +01:00, -09:00 etc 2. ID, e.g. Europe/London | |
| Works in the same way as | |
| Converts the passed
| |
LocalTime time(Partial value) | Converts the passed Partial
| |
LocalTime time(long value) | Converts the passed timestamp
| |
LocalTime time(long value) | Same as time(long value) but with timezone. Valid timezone IDs are: 1. offset, e.g. +01:00, -09:00 etc 2. ID, e.g. Europe/London | |
| Works in the same way as | |
| Converts the passed
| |
DateTime datetime(Partial value) | Converts the passed Partial
| |
DateTime datetime(long value) | Converts the passed timestamp
| |
DateTime datetime(long value, String timezone) | Same as datetime(long value) but with timezone. Valid timezone IDs are: 1. offset, e.g. +01:00, -09:00 etc 2. ID, e.g. Europe/London | |
DateTime datetime(String value, String format) | Works in the same way as | |
long timestamp(DateTime value) | Converts the passed DateTime value into timestamp. | |
DateTime decorateWithTimezone(datetime value) | Converts UTC value to user's timezone datetime |
After the date time has been converted into appropriate objects, you can use following functions:
Function | Description | |
---|---|---|
| Extracts the year of the
| |
| Extracts the month from the | |
| Extracts the week from the | |
| Extracts the day of week from the | |
| Extracts the day of month from the | |
| Extracts the day of year from the | |
| Extracts the hour of the day from the | |
| Extracts the hour of the day from the | |
| Extracts the minute of hour from the | |
| Extracts the minute of hour from the | |
| Extracts the minute of the day from the | |
| Extracts the second of minute from the | |
| Extracts the second of minute from the | |
| Extracts the second of day from the |
Basic comparison is possible by using the operators |
Function | Description | |
---|---|---|
| Determines whether the | |
| Determines whether the | |
| Determines whether the | |
| Determines whether the | |
| Determines whether the | |
| Determines whether the | |
| Determines whether the | |
| Determines whether the | |
| Determines whether the | |
| Returns the number of seconds between the two specified
| |
| Returns the number of seconds between the two specified | |
| Returns the number of minutes between the two specified | |
| Returns the number of minutes between the two specified | |
| Returns the number of hours between the two specified | |
| Returns the number of hours between the two specified | |
| Returns the number of days between the two specified
| |
| Returns the number of days between the two specified Example:
| |
| Returns the number of days between the two specified | |
| Returns the number of weeks between the two specified | |
| Returns the number of weeks between the two specified | |
| Returns the number of months between the two specified | |
| Returns the number of months between the two specified | |
| Returns the number of years between the two specified | |
| Returns the number of years between the two specified |
Manipulation with DateTime
, LocalDate
and LocalTime
objects is supported via the plus(...)
and minus(...)
functions. Both functions are changing the passed object and are returning it's changed instance. The mandatory part
parameter specifies, which part of the date/time value should be changed. Following parts are supported depending on the instance type:
LocalDate
and DateTime
- days, weeks, months, yearsLocalTime
and DateTime
- hours, minutes, secondsFunction | Description |
---|---|
| Adds the amount of specified |
| Adds the amount of specified |
| Adds the amount of specified |
| Subtracts the amount of specified |
| Subtracts the amount of specified |
| Subtracts the amount of specified |
Function | Description |
---|---|
| Outputs the |
| Outputs the |
| Outputs the |
String
based date time functionsBasic date time functions works with date time as Strings
.
Function | Description | |
---|---|---|
| Returns the current date in | |
| Works like the
| |
| Returns the current time in | |
| Works like the
| |
String actualDateTime() | Returns the current date in dd.MM.yyyy HH:mm:ss format. This function is suitable also for inducting current time for periodic import from data source which has no time column. | |
String actualDateTime(String format) | Works like the
| |
| Returns the part of the passed date or time string. This string should be in format |
Date and time formats are specified by date and time pattern strings. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. "''" represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.
The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved):
Letter | Date or Time Component | Examples |
---|---|---|
G | Era designator | AD |
y | Year | 1996; 96 |
M | Month in year | July; Jul; 07 |
w | Week in year | 27 |
W | Week in month | 2 |
D | Day in year | 189 |
d | Day in month | 10 |
F | Day of week in month | 2 |
E | Day in week | Tuesday; Tue |
a | Am/pm marker | PM |
H | Hour in day (0-23) | 0 |
k | Hour in day (1-24) | 4 |
K | Hour in am/pm (0-11) | 0 |
h | Hour in am/pm (1-12) | 12 |
m | Minute in hour | 30 |
s | Second in minute | 55 |
S | Millisecond | 978 |
z | Time zone | Pacific Standard Time; PST; GMT-08:00 |
Z | Time zone RFC 822 | -0800 |
Consider following example:
We have an import, which contains two date columns and we want the day difference of these two dates. Both date columns contains date in format yyyy/MM/dd.
def a1 = split(value(1), '/'); def date1 = [a1[0] as int, a1[1] as int, a1[2] as int] as Date; def a2 = split(value(2), '/'); def date2 = [a2[0] as int, a2[1] as int, a2[2] as int] as Date; return date2 - date1; |