public final class DateTimeFunctions
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static Value |
dateadd(java.lang.String part,
long count,
Value v)
DATEADD function.
|
static long |
datediff(java.lang.String part,
Value v1,
Value v2)
Calculate the number of crossed unit boundaries between two timestamps.
|
static Value |
extract(java.lang.String part,
Value value)
Extracts specified field from the specified date-time value.
|
static java.lang.String |
formatDateTime(java.util.Date date,
java.lang.String format,
java.lang.String locale,
java.lang.String timeZone)
Formats a date using a format string.
|
static int |
getIntDatePart(Value date,
int field)
Get the specified field of a date, however with years normalized to positive
or negative, and month starting with 1.
|
static java.lang.String[] |
getMonthsAndWeeks(int field)
Return names of month or weeks.
|
static boolean |
isDatePart(java.lang.String part)
Check if a given string is a valid date part string.
|
static java.util.Date |
parseDateTime(java.lang.String date,
java.lang.String format,
java.lang.String locale,
java.lang.String timeZone)
Parses a date using a format string.
|
static Value |
truncateDate(java.lang.String datePartStr,
Value valueDate)
Truncate the given date to the unit specified
|
public static Value dateadd(java.lang.String part, long count, Value v)
part - name of date-time partcount - count to addv - value to add topublic static long datediff(java.lang.String part,
Value v1,
Value v2)
DATEDIFF(YEAR, '2004-12-31', '2005-01-01') = 1
part - the partv1 - the first date-time valuev2 - the second date-time valuepublic static Value extract(java.lang.String part, Value value)
part - the date partvalue - the date-time valuepublic static Value truncateDate(java.lang.String datePartStr, Value valueDate)
datePartStr - the time unit (e.g. 'DAY', 'HOUR', etc.)valueDate - the datepublic static java.lang.String formatDateTime(java.util.Date date,
java.lang.String format,
java.lang.String locale,
java.lang.String timeZone)
date - the date to formatformat - the format stringlocale - the localetimeZone - the timezonepublic static int getIntDatePart(Value date, int field)
date - the date valuefield - the field type, see Function for constantspublic static java.lang.String[] getMonthsAndWeeks(int field)
field - 0 for months, 1 for weekdayspublic static boolean isDatePart(java.lang.String part)
part - the stringpublic static java.util.Date parseDateTime(java.lang.String date,
java.lang.String format,
java.lang.String locale,
java.lang.String timeZone)
date - the date to parseformat - the parsing formatlocale - the localetimeZone - the timeZone