public class DateTimeUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
EPOCH_JULIAN
The julian date of the epoch, 1970-01-01.
|
static long |
MILLIS_PER_DAY
The number of milliseconds in a day.
|
static TimeZone |
UTC_ZONE
The UTC time zone.
|
Constructor and Description |
---|
DateTimeUtils() |
Modifier and Type | Method and Description |
---|---|
static Timestamp |
dateToTimestampWithLocalZone(int date,
TimeZone tz) |
static String |
formatDate(int date)
Helper for CAST({date} AS VARCHAR(n)).
|
static String |
formatLocalDateTime(java.time.LocalDateTime localDateTime,
int precision)
Format a
LocalDateTime to yyyy-MM-dd HH:mm:ss[.nano] string. |
static String |
formatTimestamp(Timestamp ts,
int precision) |
static String |
formatTimestamp(Timestamp ts,
TimeZone tz,
int precision) |
static String |
formatTimestampMillis(int time,
int precision) |
static Integer |
parseDate(String s) |
static Integer |
parseTime(String v) |
static Timestamp |
parseTimestampData(String dateStr,
int precision) |
static Timestamp |
parseTimestampData(String dateStr,
int precision,
TimeZone timeZone) |
static Timestamp |
timestampToTimestampWithLocalZone(Timestamp ts,
TimeZone tz) |
static int |
timestampWithLocalZoneToDate(Timestamp ts,
TimeZone tz) |
static int |
timestampWithLocalZoneToTime(Timestamp ts,
TimeZone tz) |
static Timestamp |
timestampWithLocalZoneToTimestamp(Timestamp ts,
TimeZone tz) |
static Timestamp |
timeToTimestampWithLocalZone(int time,
TimeZone tz) |
static int |
toInternal(Date date)
Converts the Java type used for UDF parameters of SQL DATE type (
Date ) to
internal representation (int). |
static int |
toInternal(java.time.LocalDate date) |
static int |
toInternal(java.time.LocalTime time) |
static Timestamp |
toInternal(long millis,
int nanos) |
static int |
toInternal(Time time)
Converts the Java type used for UDF parameters of SQL TIME type (
Time ) to
internal representation (int). |
static java.time.LocalDate |
toLocalDate(int date) |
static java.time.LocalDateTime |
toLocalDateTime(long timeMills) |
static java.time.LocalDateTime |
toLocalDateTime(long timeMills,
java.time.ZoneId zoneId) |
static java.time.LocalDateTime |
toLocalDateTime(String dateStr,
int precision) |
static java.time.LocalTime |
toLocalTime(int time) |
static Date |
toSQLDate(int v)
Converts the internal representation of a SQL DATE (int) to the Java type used for UDF
parameters (
Date ). |
static Time |
toSQLTime(int v)
Converts the internal representation of a SQL TIME (int) to the Java type used for UDF
parameters (
Time ). |
static Timestamp |
truncate(Timestamp ts,
int precision) |
static long |
unixTimestamp(long ts)
Returns the value of the timestamp to seconds since '1970-01-01 00:00:00' UTC.
|
public static final int EPOCH_JULIAN
public static final long MILLIS_PER_DAY
This is the modulo 'mask' used when converting TIMESTAMP values to DATE and TIME values.
public static final TimeZone UTC_ZONE
public static Date toSQLDate(int v)
Date
).public static Time toSQLTime(int v)
Time
).public static int toInternal(Date date)
Date
) to
internal representation (int).public static int toInternal(Time time)
Time
) to
internal representation (int).
Converse of toSQLTime(int)
.
public static Timestamp toInternal(long millis, int nanos)
public static int toInternal(java.time.LocalDate date)
public static int toInternal(java.time.LocalTime time)
public static String formatLocalDateTime(java.time.LocalDateTime localDateTime, int precision)
LocalDateTime
to yyyy-MM-dd HH:mm:ss[.nano] string.precision
- how many digits of nanoseconds to be retainedpublic static java.time.LocalDate toLocalDate(int date)
public static java.time.LocalTime toLocalTime(int time)
public static String formatTimestampMillis(int time, int precision)
public static String formatDate(int date)
public static Timestamp parseTimestampData(String dateStr, int precision) throws java.time.DateTimeException
java.time.DateTimeException
public static Timestamp parseTimestampData(String dateStr, int precision, TimeZone timeZone) throws java.time.DateTimeException
java.time.DateTimeException
public static java.time.LocalDateTime toLocalDateTime(long timeMills)
public static java.time.LocalDateTime toLocalDateTime(long timeMills, java.time.ZoneId zoneId)
public static java.time.LocalDateTime toLocalDateTime(String dateStr, int precision)
public static long unixTimestamp(long ts)
public static Timestamp timestampToTimestampWithLocalZone(Timestamp ts, TimeZone tz)
public static Timestamp timestampWithLocalZoneToTimestamp(Timestamp ts, TimeZone tz)
public static int timestampWithLocalZoneToDate(Timestamp ts, TimeZone tz)
public static int timestampWithLocalZoneToTime(Timestamp ts, TimeZone tz)
public static Timestamp dateToTimestampWithLocalZone(int date, TimeZone tz)
public static Timestamp timeToTimestampWithLocalZone(int time, TimeZone tz)
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.