The TalendDate
routines allow you to carry out different kinds of
operations and checks concerning the format of Date expressions.
To access these routines, double-click TalendDate under the system folder:
Routine |
Description |
Syntax |
---|---|---|
|
Adds n days, n months, n hours, n minutes or n seconds to a Java date and returns the new date. The Date format is: yyyy, MM, dd, HH, mm, ss or SSS. |
|
|
Compares all or part of two dates according to the format specified.
Returns |
|
|
Returns the difference between two dates in terms of days, months or years according to the comparison parameter specified. |
|
|
Returns the difference between two dates by floor in terms of years, months, days, hours, minutes, seconds or milliseconds according to the comparison parameter specified. |
|
|
Returns a date string which corresponds to the format specified. |
|
|
Changes a date into a date/hour string according to the format used in the target country. |
|
|
Returns the current date. No entry parameter is required. |
|
|
Returns the current date and hour in the format specified (optional).
This string can contain fixed character strings or variables linked
to the date. By default, the string is returned in the format of
|
|
|
Changes the date of an event to the first day of the current month and returns the new date. |
|
|
Changes the date of an event to the last day of the current month and returns the new date. |
|
|
Returns part of a date according to the format specified. This string can contain fixed character strings or variables linked to the date. |
|
|
Returns a random date, in the ISO format. |
|
|
Checks whether the date string corresponds to the format specified. Returns the boolean value true or false according to the outcome. |
|
|
Changes a string into a Date. Returns a date in the standard format. |
|
|
changes a string into a Date in UTC. Returns a date in the UTC format. |
|
|
Parses a .string according to a specified format and extracts the date. Returns the date according to the local format specified. |
|
|
Modifies part of a date according to the part and value of the date specified and the format specified. |
|
|
Converts a date to a character string. |
|
|
Converts a character string to a Date/Time datatype. |
For example, |
|
Adds a specified amount to one part of a datetime value, and returns a date in the same format as the date you pass to the function. |
For example, if
|
Although "yyyy" and "YYYY" in the date format return the same year number in most cases , "YYYY" may not work as expected when used:
- at the first week of a year if the year does not start by the first day of the week.
- at the last week of a year if the year does not end by the last day of the week.
For example, when calculating what date it is 3 days before January 2, 2016, the code below would return a wrong date:
System.out.println(TalendDate.formatDate("YYYY-MM-dd", TalendDate.addDate(TalendDate.TO_DATE("01/02/2016 08:10:30.123"), -3, "dd")));
while the following code would work as expected:
System.out.println(TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.TO_DATE("01/02/2016 08:10:30.123"), -3, "dd")));
Therefore, you should typically use "yyyy", which represents calendar year.