public final class DateTimeFunctions extends Object
Modifier and Type | Method and Description |
---|---|
static Value |
dateadd(String part,
long count,
Value v)
DATEADD function.
|
static long |
datediff(String part,
Value v1,
Value v2)
Calculate the number of crossed unit boundaries between two timestamps.
|
static Value |
extract(String part,
Value value)
Extracts specified field from the specified date-time value.
|
static String |
formatDateTime(Date date,
String format,
String locale,
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 String[] |
getMonthsAndWeeks(int field)
Return names of month or weeks.
|
static boolean |
isDatePart(String part)
Check if a given string is a valid date part string.
|
static Date |
parseDateTime(String date,
String format,
String locale,
String timeZone)
Parses a date using a format string.
|
static Value |
truncateDate(String datePartStr,
Value valueDate)
Truncate the given date to the unit specified
|
public static Value dateadd(String part, long count, Value v)
part
- name of date-time partcount
- count to addv
- value to add topublic static long datediff(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(String part, Value value)
part
- the date partvalue
- the date-time valuepublic static Value truncateDate(String datePartStr, Value valueDate)
datePartStr
- the time unit (e.g. 'DAY', 'HOUR', etc.)valueDate
- the datepublic static String formatDateTime(Date date, String format, String locale, 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 String[] getMonthsAndWeeks(int field)
field
- 0 for months, 1 for weekdayspublic static boolean isDatePart(String part)
part
- the stringCopyright © 2020 JBoss by Red Hat. All rights reserved.