public class DateTimeUtils extends Object
Modifier and Type | Field and Description |
---|---|
static TimeZone |
CST_TIMEZONE |
static TimeZone |
LOCALTZ
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static long |
epochDaysToMillis(long epochDays,
TimeZone tz)
Gets the instant in time at midnight in the specified time zone
corresponding to the given date.
|
static String |
format(DateValued value)
Converts a date value into an ISO8601 date formatted string.
|
static String |
format(TimestampValued value)
Converts a time stamp value into an ISO8601 time stamp formatted string.
|
static String |
format(TimeValued value)
Converts a time of day value into an ISO8601 time formatted string.
|
static String |
formatDaysSinceEpoch(long epochDays)
Converts a date, expressed as days, into an ISO8601 date formatted string.
|
static String |
formatEpochTime(long seconds,
int nanos,
int offsetSecs)
Converts a time stamp, expressed as component values, into an ISO8601 time stamp formatted string.
|
static String |
formatMillisSinceMidnight(int dayMillis)
Converts a time of day, expressed as milliseconds, into an ISO8601 time formatted string.
|
static org.joda.time.chrono.ISOChronology |
getDefaultChronology() |
static TimeZone |
getDefaultTimeZone() |
static int |
normalizeMillisSinceMidnight(long millis)
Normalize elapsed milliseconds to the standard range from midnight
to midnight.
|
protected static int |
parseIntField(String str,
int startPos,
int endPos) |
static void |
parseInto(String text,
DateSettable buffer)
Parses a date in ISO8601 format, storing the result
into a date valued container.
|
static void |
parseInto(String text,
TimeSettable buffer)
Parses a time of day in ISO8601 time format, storing the result
into a time valued container.
|
static void |
parseInto(String text,
TimestampSettable buffer)
Parses a timestamp in ISO8601 format, storing the result
into a timestamp valued container..
|
static int |
parseTimeFields(String str,
com.pervasive.datarush.tokens.scalar.DateTimeUtils.TimeParsingContext ctx,
int pos) |
static long |
parseToDaysSinceEpoch(String text)
Parses a date in ISO8601 time format into days since epoch.
|
static int |
parseToMillisSinceMidnight(String text)
Parses a time of day in ISO8601 time format into milliseconds since midnight.
|
static Date |
toDate(long epochDays)
Gets the instant in time at midnight in the default time zone
corresponding to the given date.
|
static Date |
toDate(long epochDays,
TimeZone tz)
Gets the instant in time at midnight in the specified time zone
corresponding to the given date.
|
static long |
toDaysSinceEpoch(Date date)
Gets the date represented by the given instant in the default time zone
as days since epoch.
|
static long |
toDaysSinceEpoch(Date date,
TimeZone tz)
Gets the date represented by the given instant in the specified time zone
as days since epoch.
|
static long |
toDaysSinceEpoch(int year,
int monthOfYear,
int dayOfMonth)
Gets the specified date as days since epoch.
|
static long |
toDaysSinceEpoch(long millis)
Gets the date represented by the given instant in the default time zone
as days since epoch.
|
static long |
toDaysSinceEpoch(long millis,
TimeZone tz)
Gets the date represented by the given instant in the specified time zone
as days since epoch.
|
static void |
toEpochTime(Date date,
TimestampSettable buffer)
Stores the given instant into a time stamp buffer using the
default time zone for the offset.
|
static void |
toEpochTime(Date date,
TimeZone tz,
TimestampSettable buffer)
Stores the given instant into a time stamp buffer using the
specified time zone for the offset.
|
static void |
toEpochTime(long millis,
TimestampSettable buffer)
Stores the given instant into a time stamp buffer using the
default time zone for the offset.
|
static void |
toEpochTime(long millis,
TimeZone tz,
TimestampSettable buffer)
Stores the given instant into a time stamp buffer using the
specified time zone for the offset.
|
static void |
toEpochTime(Timestamp timestamp,
TimestampSettable buffer)
Stores the given instant into a time stamp buffer using the
default time zone for the offset.
|
static void |
toEpochTime(Timestamp timestamp,
TimeZone tz,
TimestampSettable buffer)
Stores the given instant into a time stamp buffer using the
specified time zone for the offset.
|
static int |
toMillisSinceMidnight(Date time)
Gets the time of day represented by the given instant in the default time zone
as milliseconds since midnight.
|
static int |
toMillisSinceMidnight(Date time,
TimeZone tz)
Gets the time of day represented by the given instant in the specified time zone
as milliseconds since midnight.
|
static int |
toMillisSinceMidnight(int hourOfDay,
int minuteOfHour,
int secondOfMinute)
Gets the time, in 24-hour format, as milliseconds since midnight.
|
static int |
toMillisSinceMidnight(long instant)
Gets the time of day represented by the given instant in the default time zone
as milliseconds since midnight.
|
static int |
toMillisSinceMidnight(long instant,
int tzoffset)
Gets the time of day represented by the given instant in the specified time zone
as milliseconds since midnight.
|
static int |
toMillisSinceMidnight(long instant,
TimeZone tz)
Gets the time of day represented by the given instant in the specified time zone
as milliseconds since midnight.
|
static Time |
toTime(long dayMillis)
Gets the instant in time on January 1, 1970 in the default time zone
corresponding to the given time of day.
|
static Time |
toTime(long dayMillis,
TimeZone tz)
Gets the instant in time on January 1, 1970 in the specified time zone
corresponding to the given time of day.
|
static Timestamp |
toTimestamp(long epochSecs,
int subsecNanos,
int offsetSecs)
Gets the instant in time on corresponding to the specified epoch time.
|
static void |
withCSTTimeZone(Runnable runnable) |
@Deprecated public static final TimeZone LOCALTZ
TimeZone.getDefault()
.
Deprecated because this static instance is unsafe to use because tests or
end users may want to set the default Timezone late and that should be respected.
Only use TimeZone.getDefault directly instead.public static final TimeZone CST_TIMEZONE
protected static int parseIntField(String str, int startPos, int endPos)
public static int parseTimeFields(String str, com.pervasive.datarush.tokens.scalar.DateTimeUtils.TimeParsingContext ctx, int pos)
public static long toDaysSinceEpoch(int year, int monthOfYear, int dayOfMonth)
year
- the year portion of the datemonthOfYear
- the month portion of the date. Months are counted as on
a calendar, starting with 1 for January.dayOfMonth
- the day portion of the datepublic static long toDaysSinceEpoch(long millis)
millis
- the instant in time to convertpublic static long toDaysSinceEpoch(long millis, TimeZone tz)
millis
- the instant in time to converttz
- the time zone relative to which to interpret the instantpublic static long toDaysSinceEpoch(Date date)
date
- the instant in time to converttz
- the time zone relative to which to interpret the instantpublic static long toDaysSinceEpoch(Date date, TimeZone tz)
date
- the instant in time to converttz
- the time zone relative to which to interpret the instantpublic static long epochDaysToMillis(long epochDays, TimeZone tz)
epochDays
- the number of milliseconds elapsed since January 1, 1970tz
- the time zone relative to which to convert the datepublic static Date toDate(long epochDays)
epochDays
- the number of milliseconds elapsed since January 1, 1970Date
object representing the datepublic static Date toDate(long epochDays, TimeZone tz)
epochDays
- the number of milliseconds elapsed since January 1, 1970tz
- the time zone relative to which to convert the dateDate
object representing the datepublic static long parseToDaysSinceEpoch(String text)
text
- a date in ISO8601 formatpublic static void parseInto(String text, DateSettable buffer)
text
- a date in ISO8601 format.buffer
- the container in which to store the parsed valuepublic static String formatDaysSinceEpoch(long epochDays)
epochDays
- the number of days elapsed since January 1, 1970public static String format(DateValued value)
value
- the date value to convertpublic static int normalizeMillisSinceMidnight(long millis)
millis
- milliseconds elapsed since midnightpublic static int toMillisSinceMidnight(int hourOfDay, int minuteOfHour, int secondOfMinute)
hourOfDay
- the hour portion of the timeminuteOfHour
- the minutes portion of the timesecondOfMinute
- the seconds portion of the timepublic static int toMillisSinceMidnight(long instant)
instant
- the instant in time to convertpublic static int toMillisSinceMidnight(long instant, TimeZone tz)
instant
- the instant in time to converttz
- the time zone relative to which to interpret the instantpublic static int toMillisSinceMidnight(long instant, int tzoffset)
instant
- the instant in time to converttzoffset
- the time zone offset with which to interpret the instantpublic static int toMillisSinceMidnight(Date time)
time
- the instant in time to convertpublic static int toMillisSinceMidnight(Date time, TimeZone tz)
time
- the instant in time to converttz
- the time zone relative to which to interpret the instantpublic static Time toTime(long dayMillis)
dayMillis
- the number of milliseconds elapsed since midnightTime
object representing the time of daypublic static Time toTime(long dayMillis, TimeZone tz)
dayMillis
- the number of milliseconds elapsed since midnighttz
- the time zone relative to which to convert the time of dayTime
object representing the time of daypublic static int parseToMillisSinceMidnight(String text)
text
- a time of day in ISO8601 formatpublic static void parseInto(String text, TimeSettable buffer)
text
- a time of day in ISO8601 format.buffer
- the container in which to store the parsed valuepublic static String formatMillisSinceMidnight(int dayMillis)
millisSinceMidnight
- the number of milliseconds elapsed since midnightpublic static String format(TimeValued value)
value
- the time value to formatpublic static void toEpochTime(long millis, TimestampSettable buffer)
millis
- the instant in time to convertbuffer
- the container into which to store the valuepublic static void toEpochTime(long millis, TimeZone tz, TimestampSettable buffer)
millis
- the instant in time to converttz
- the time zone relative to which to interpret the instantbuffer
- the container into which to store the valuepublic static void toEpochTime(Date date, TimestampSettable buffer)
date
- the instant in time to convertbuffer
- the container into which to store the valuepublic static void toEpochTime(Date date, TimeZone tz, TimestampSettable buffer)
date
- the instant in time to converttz
- the time zone relative to which to interpret the instantbuffer
- the container into which to store the valuepublic static void toEpochTime(Timestamp timestamp, TimestampSettable buffer)
timestamp
- the instant in time to convertbuffer
- the container into which to store the valuepublic static void toEpochTime(Timestamp timestamp, TimeZone tz, TimestampSettable buffer)
timestamp
- the instant in time to converttz
- the time zone relative to which to interpret the instantbuffer
- the container into which to store the valuepublic static Timestamp toTimestamp(long epochSecs, int subsecNanos, int offsetSecs)
epochSecs
- number of seconds since Java epochsubsecNanos
- fractional portion of epoch time in nanosecondsoffsetSecs
- time zone + daylight saving time offset in secondsdayMillis
- the number of milliseconds elapsed since midnightTimestamp
object representing the time stamppublic static void parseInto(String text, TimestampSettable buffer)
text
- a timestamp in ISO8601 format.buffer
- the container in which to store the parsed valuepublic static String formatEpochTime(long seconds, int nanos, int offsetSecs)
seconds
- number of seconds since Java epochnanos
- fractional portion of epoch time in nanosecondsoffsetSeconds
- time zone and daylight saving time offset, in secondspublic static String format(TimestampValued value)
value
- the time stamp value to formatpublic static TimeZone getDefaultTimeZone()
public static void withCSTTimeZone(Runnable runnable)
public static org.joda.time.chrono.ISOChronology getDefaultChronology()
Copyright © 2021 Actian Corporation. All rights reserved.