|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.h2.util.DateTimeUtils
public class DateTimeUtils
This utility class contains time conversion functions.
Date value: a bit field with bits for the year, month, and day. Absolute day: the day number (0 means 1970-01-01).
| Field Summary | |
|---|---|
static long |
MILLIS_PER_DAY
The number of milliseconds per day. |
| Method Summary | |
|---|---|
static long |
absoluteDayFromDateValue(long dateValue)
Calculate the absolute day from a date value. |
static ValueDate |
convertDate(java.sql.Date x,
java.util.Calendar calendar)
Convert the date using the specified calendar. |
static java.sql.Date |
convertDate(Value value,
java.util.Calendar calendar)
Convert the date to the specified time zone. |
static java.sql.Date |
convertDateValueToDate(long dateValue)
Convert a date value to a date, using the default timezone. |
static java.sql.Timestamp |
convertDateValueToTimestamp(long dateValue,
long nanos)
Convert a date value / time value to a timestamp, using the default timezone. |
static java.sql.Time |
convertNanoToTime(long nanos)
Convert a time value to a time, using the default timezone. |
static ValueTime |
convertTime(java.sql.Time x,
java.util.Calendar calendar)
Convert the time using the specified calendar. |
static java.sql.Time |
convertTime(Value value,
java.util.Calendar calendar)
Convert the time to the specified time zone. |
static ValueTimestamp |
convertTimestamp(java.sql.Timestamp x,
java.util.Calendar calendar)
Convert the timestamp using the specified calendar. |
static java.sql.Timestamp |
convertTimestamp(Value value,
java.util.Calendar calendar)
Convert the timestamp to the specified time zone. |
static long |
convertToLocal(java.util.Date x,
java.util.Calendar target)
Convert a date to the specified time zone. |
static long |
dateValue(long year,
int month,
int day)
Get the date value from a given date. |
static long |
dateValueFromAbsoluteDay(long absoluteDay)
Calculate the date value from an absolute day. |
static long |
dateValueFromDate(long ms)
Calculate the date value (in the default timezone) from a given time in milliseconds in UTC. |
static int |
dayFromDateValue(long x)
Get the day of month from a date 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 |
getDatePart(java.util.Date d,
int field)
Get the specified field of a date, however with years normalized to positive or negative, and month starting with 1. |
static int |
getIsoDayOfWeek(java.util.Date date)
Return the day of week according to the ISO 8601 specification. |
static int |
getIsoWeek(java.util.Date date)
Returns the week of the year according to the ISO 8601 specification. |
static int |
getIsoYear(java.util.Date date)
Returns the year according to the ISO week definition. |
static long |
getMillis(java.util.TimeZone tz,
int year,
int month,
int day,
int hour,
int minute,
int second,
int millis)
Calculate the milliseconds since 1970-01-01 (UTC) for the given date and time (in the specified timezone). |
static long |
getTimeLocalWithoutDst(java.util.Date d)
Get the number of milliseconds since 1970-01-01 in the local timezone, but without daylight saving time into account. |
static long |
getTimeUTCWithoutDst(long millis)
Convert the number of milliseconds since 1970-01-01 in the local timezone to UTC, but without daylight saving time into account. |
static boolean |
isValidDate(int year,
int month,
int day)
Verify if the specified date is valid. |
static int |
monthFromDateValue(long x)
Get the month from a date value. |
static long |
nanosFromDate(long ms)
Calculate the nanoseconds since midnight (in the default timezone) from a given time in milliseconds in UTC. |
static ValueTimestamp |
normalizeTimestamp(long absoluteDay,
long nanos)
Calculate the normalized timestamp. |
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 long |
parseDateValue(java.lang.String s,
int start,
int end)
Parse a date string. |
static long |
parseTimeNanos(java.lang.String s,
int start,
int end,
boolean timeOfDay)
Parse a time string. |
static void |
resetCalendar()
Reset the calendar, for example after changing the default timezone. |
static int |
yearFromDateValue(long x)
Get the year from a date value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long MILLIS_PER_DAY
| Method Detail |
|---|
public static void resetCalendar()
public static java.sql.Date convertDate(Value value,
java.util.Calendar calendar)
value - the date (might be ValueNull)calendar - the calendar
public static java.sql.Time convertTime(Value value,
java.util.Calendar calendar)
value - the time (might be ValueNull)calendar - the calendar
public static java.sql.Timestamp convertTimestamp(Value value,
java.util.Calendar calendar)
value - the timestamp (might be ValueNull)calendar - the calendar
public static ValueDate convertDate(java.sql.Date x,
java.util.Calendar calendar)
x - the datecalendar - the calendar
public static ValueTime convertTime(java.sql.Time x,
java.util.Calendar calendar)
x - the timecalendar - the calendar
public static long convertToLocal(java.util.Date x,
java.util.Calendar target)
x - the date to converttarget - the calendar with the target timezone
public static ValueTimestamp convertTimestamp(java.sql.Timestamp x,
java.util.Calendar calendar)
x - the timecalendar - the calendar
public static long parseDateValue(java.lang.String s,
int start,
int end)
s - the string to parsestart - the parse index startend - the parse index end
java.lang.IllegalArgumentException - if there is a problem
public static long parseTimeNanos(java.lang.String s,
int start,
int end,
boolean timeOfDay)
s - the string to parsestart - the parse index startend - the parse index endtimeOfDay - whether the result need to be within 0 (inclusive) and 1
day (exclusive)
java.lang.IllegalArgumentException - if there is a problem
public static long getMillis(java.util.TimeZone tz,
int year,
int month,
int day,
int hour,
int minute,
int second,
int millis)
tz - the timezone of the parametersyear - the absolute year (positive or negative)month - the month (1-12)day - the day (1-31)hour - the hour (0-23)minute - the minutes (0-59)second - the number of seconds (0-59)millis - the number of milliseconds
public static int getDatePart(java.util.Date d,
int field)
d - the datefield - the field type
public static long getTimeLocalWithoutDst(java.util.Date d)
d - the date
public static long getTimeUTCWithoutDst(long millis)
millis - the number of milliseconds in the local timezone
public static int getIsoDayOfWeek(java.util.Date date)
date - the date object which day of week should be calculated
public static int getIsoWeek(java.util.Date date)
date - the date object which week of year should be calculated
public static int getIsoYear(java.util.Date date)
date - the date object which year should be calculated
public 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 timezone
public 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
public static boolean isValidDate(int year,
int month,
int day)
year - the yearmonth - the month (January is 1)day - the day (1 is the first of the month)
public static java.sql.Date convertDateValueToDate(long dateValue)
dateValue - the date value
public static java.sql.Timestamp convertDateValueToTimestamp(long dateValue,
long nanos)
dateValue - the date valuenanos - the nanoseconds since midnight
public static java.sql.Time convertNanoToTime(long nanos)
nanos - the nanoseconds since midnight
public static int yearFromDateValue(long x)
x - the date value
public static int monthFromDateValue(long x)
x - the date value
public static int dayFromDateValue(long x)
x - the date value
public static long dateValue(long year,
int month,
int day)
year - the yearmonth - the month (1..12)day - the day (1..31)
public static long dateValueFromDate(long ms)
ms - the milliseconds
public static long nanosFromDate(long ms)
ms - the milliseconds
public static ValueTimestamp normalizeTimestamp(long absoluteDay,
long nanos)
absoluteDay - the absolute daynanos - the nanoseconds (may be negative or larger than one day)
public static long absoluteDayFromDateValue(long dateValue)
dateValue - the date value
public static long dateValueFromAbsoluteDay(long absoluteDay)
absoluteDay - the absolute day
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||