Open Studio for Big Data
Open Studio for Data Integration
Open Studio for ESB
The TalendDate routine contains several functions which allow you to carry out different kinds of operations and checks concerning the format of Date expressions.
yyyy-MM-dd
or yyyy-MM-dd HH:mm:ss
, where there is no
check for the format of the input date string in order to achieve better performance. You
need to make sure the input date string matches the set pattern precisely when using either
of these two patterns.You can access these functions by double-clicking the TalendDate node under the system routines folder in the Repository tree view.
Function |
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 The |
|
|
Returns the difference between two dates in terms of years, months, days, hours, minutes, seconds, or milliseconds according to the comparison parameter specified. The The |
For example, |
|
Returns the difference between two dates in terms of years or months according to the comparison parameter specified. The value is rounded down to the nearest integer. The |
For example,
|
diffDateIgnoreDST
|
Returns the difference between two dates in terms of days, months or years according to the comparison parameter specified, ignoring the DST. The |
TalendDate.diffDateIgnoreDST(Date1(), Date2(),[String
dateType])
|
|
Returns a date string which corresponds to the format specified. |
|
|
Formats a date into the specified format date/time string under the given timezone. |
|
|
Formats a date into the specified format date/time string under the UTC timezone. |
|
|
Changes a date into a date/hour string according to the format used in the target country. |
|
|
Formats date to MSSQL 2008 type datetimeoffset ISO 8601 string with local time zone format string: yyyy-MM-dd HH:mm:ss.SSSXXX (JDK7 support it). |
|
|
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. |
where, pattern specifies the format of the date to be
checked. For example, |
|
Tests string value as a date with right pattern using strict rules. This validation uses Java 8 time tools. The range of time-zone offsets is restricted to -18:00 to 18:00 inclusive. Returns a boolean value indicating whether the stringDate is a date string with a right pattern. |
|
|
Changes a string into a Date. Returns a date in the specified 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.