Package io.trino.type
Class DateTimes
- java.lang.Object
-
- io.trino.type.DateTimes
-
public final class DateTimes extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static PatternDATETIME_PATTERNstatic longHOURS_PER_DAYstatic longMICROSECONDS_PER_DAYstatic intMICROSECONDS_PER_MILLISECONDstatic intMICROSECONDS_PER_SECONDstatic longMILLISECONDS_PER_DAYstatic longMILLISECONDS_PER_MINUTEstatic intMILLISECONDS_PER_SECONDstatic longMINUTES_PER_HOURstatic longNANOSECONDS_PER_DAYstatic longNANOSECONDS_PER_HOURstatic intNANOSECONDS_PER_MICROSECONDstatic intNANOSECONDS_PER_MILLISECONDstatic longNANOSECONDS_PER_MINUTEstatic longNANOSECONDS_PER_SECONDstatic longPICOSECONDS_PER_DAYstatic longPICOSECONDS_PER_HOURstatic intPICOSECONDS_PER_MICROSECONDstatic intPICOSECONDS_PER_MILLISECONDstatic longPICOSECONDS_PER_MINUTEstatic intPICOSECONDS_PER_NANOSECONDstatic longPICOSECONDS_PER_SECONDstatic longSECONDS_PER_DAYstatic longSECONDS_PER_MINUTEstatic PatternTIME_PATTERN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcalculateOffsetMinutes(int sign, int offsetHour, int offsetMinute)static longepochMicrosToMillisWithRounding(long epochMicros)static longepochSecondToMicrosWithRounding(long epochSecond, long picoOfSecond)static intextractTimePrecision(String value)static intextractTimestampPrecision(String value)static StringformatTimestamp(int precision, long epochMicros, int picosOfMicro, ZoneId zoneId)Formats a timestamp of the given precision.static StringformatTimestamp(int precision, long epochMicros, int picosOfMicro, ZoneId zoneId, DateTimeFormatter yearToSecondFormatter)Formats a timestamp of the given precision.static StringformatTimestamp(int precision, LocalDateTime dateTime, long picoFraction, DateTimeFormatter yearToSecondFormatter, Consumer<StringBuilder> zoneIdFormatter)static StringformatTimestampWithTimeZone(int precision, long epochMillis, int picosOfMilli, ZoneId zoneId)static intgetMicrosOfMilli(long epochMicros)static intgetMicrosOfSecond(long epochMicros)static intgetMillisOfSecond(long epochMillis)static intgetOffsetMinutes(Instant instant, TimeZoneKey zoneKey)static booleanisValidOffset(int hour, int minute)static LongTimestamplongTimestamp(long epochSecond, long fractionInPicos)static LongTimestamplongTimestamp(long precision, Instant start)static LongTimestampWithTimeZonelongTimestampWithTimeZone(long epochSecond, long fractionInPicos, ZoneId zoneId)static LongTimestampWithTimeZonelongTimestampWithTimeZone(long precision, Instant start, TimeZoneKey timeZoneKey)static LongTimeWithTimeZoneparseLongTimeWithTimeZone(String value)static longparseShortTimeWithTimeZone(String value)static longparseTime(String value)static ObjectparseTimestamp(int precision, String value)static ObjectparseTimestampWithTimeZone(int precision, String value)static ObjectparseTimeWithTimeZone(int precision, String value)static longrescale(long value, int fromPrecision, int toPrecision)Rescales a value of the given precision to another precision by adding 0s or truncating.static longrescaleWithRounding(long value, int fromPrecision, int toPrecision)static longround(long value, int magnitude)static longroundToEpochMillis(LongTimestampWithTimeZone timestamp)static longroundToNearest(long value, long bound)static longscaleEpochMicrosToMillis(long value)static longscaleEpochMicrosToSeconds(long epochMicros)static longscaleEpochMillisToMicros(long epochMillis)static longscaleEpochMillisToSeconds(long epochMillis)static longscaleFactor(int fromPrecision, int toPrecision)static booleantimeHasTimeZone(String value)static booleantimestampHasTimeZone(String value)static longtoEpochMicros(long epochMillis, int picosOfMilli)static LocalDateTimetoLocalDateTime(TimestampType type, Block block, int position)static ZonedDateTimetoZonedDateTime(TimestampWithTimeZoneType type, Block block, int position)
-
-
-
Field Detail
-
DATETIME_PATTERN
public static final Pattern DATETIME_PATTERN
-
TIME_PATTERN
public static final Pattern TIME_PATTERN
-
MILLISECONDS_PER_SECOND
public static final int MILLISECONDS_PER_SECOND
- See Also:
- Constant Field Values
-
MILLISECONDS_PER_MINUTE
public static final long MILLISECONDS_PER_MINUTE
- See Also:
- Constant Field Values
-
MILLISECONDS_PER_DAY
public static final long MILLISECONDS_PER_DAY
- See Also:
- Constant Field Values
-
MICROSECONDS_PER_SECOND
public static final int MICROSECONDS_PER_SECOND
- See Also:
- Constant Field Values
-
MICROSECONDS_PER_MILLISECOND
public static final int MICROSECONDS_PER_MILLISECOND
- See Also:
- Constant Field Values
-
MICROSECONDS_PER_DAY
public static final long MICROSECONDS_PER_DAY
- See Also:
- Constant Field Values
-
PICOSECONDS_PER_SECOND
public static final long PICOSECONDS_PER_SECOND
- See Also:
- Constant Field Values
-
NANOSECONDS_PER_SECOND
public static final long NANOSECONDS_PER_SECOND
- See Also:
- Constant Field Values
-
NANOSECONDS_PER_MINUTE
public static final long NANOSECONDS_PER_MINUTE
- See Also:
- Constant Field Values
-
NANOSECONDS_PER_HOUR
public static final long NANOSECONDS_PER_HOUR
- See Also:
- Constant Field Values
-
NANOSECONDS_PER_DAY
public static final long NANOSECONDS_PER_DAY
- See Also:
- Constant Field Values
-
NANOSECONDS_PER_MILLISECOND
public static final int NANOSECONDS_PER_MILLISECOND
- See Also:
- Constant Field Values
-
NANOSECONDS_PER_MICROSECOND
public static final int NANOSECONDS_PER_MICROSECOND
- See Also:
- Constant Field Values
-
PICOSECONDS_PER_MILLISECOND
public static final int PICOSECONDS_PER_MILLISECOND
- See Also:
- Constant Field Values
-
PICOSECONDS_PER_MICROSECOND
public static final int PICOSECONDS_PER_MICROSECOND
- See Also:
- Constant Field Values
-
PICOSECONDS_PER_NANOSECOND
public static final int PICOSECONDS_PER_NANOSECOND
- See Also:
- Constant Field Values
-
SECONDS_PER_MINUTE
public static final long SECONDS_PER_MINUTE
- See Also:
- Constant Field Values
-
MINUTES_PER_HOUR
public static final long MINUTES_PER_HOUR
- See Also:
- Constant Field Values
-
HOURS_PER_DAY
public static final long HOURS_PER_DAY
- See Also:
- Constant Field Values
-
PICOSECONDS_PER_MINUTE
public static final long PICOSECONDS_PER_MINUTE
- See Also:
- Constant Field Values
-
PICOSECONDS_PER_HOUR
public static final long PICOSECONDS_PER_HOUR
- See Also:
- Constant Field Values
-
PICOSECONDS_PER_DAY
public static final long PICOSECONDS_PER_DAY
- See Also:
- Constant Field Values
-
SECONDS_PER_DAY
public static final long SECONDS_PER_DAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
scaleEpochMicrosToMillis
public static long scaleEpochMicrosToMillis(long value)
-
epochMicrosToMillisWithRounding
public static long epochMicrosToMillisWithRounding(long epochMicros)
-
scaleEpochMillisToSeconds
public static long scaleEpochMillisToSeconds(long epochMillis)
-
scaleEpochMicrosToSeconds
public static long scaleEpochMicrosToSeconds(long epochMicros)
-
scaleEpochMillisToMicros
public static long scaleEpochMillisToMicros(long epochMillis)
-
epochSecondToMicrosWithRounding
public static long epochSecondToMicrosWithRounding(long epochSecond, long picoOfSecond)
-
getMicrosOfSecond
public static int getMicrosOfSecond(long epochMicros)
-
getMillisOfSecond
public static int getMillisOfSecond(long epochMillis)
-
getMicrosOfMilli
public static int getMicrosOfMilli(long epochMicros)
-
toEpochMicros
public static long toEpochMicros(long epochMillis, int picosOfMilli)
-
round
public static long round(long value, int magnitude)
-
roundToNearest
public static long roundToNearest(long value, long bound)
-
scaleFactor
public static long scaleFactor(int fromPrecision, int toPrecision)
-
rescale
public static long rescale(long value, int fromPrecision, int toPrecision)Rescales a value of the given precision to another precision by adding 0s or truncating.
-
rescaleWithRounding
public static long rescaleWithRounding(long value, int fromPrecision, int toPrecision)
-
timestampHasTimeZone
public static boolean timestampHasTimeZone(String value)
-
extractTimestampPrecision
public static int extractTimestampPrecision(String value)
-
toLocalDateTime
public static LocalDateTime toLocalDateTime(TimestampType type, Block block, int position)
-
toZonedDateTime
public static ZonedDateTime toZonedDateTime(TimestampWithTimeZoneType type, Block block, int position)
-
formatTimestamp
public static String formatTimestamp(int precision, long epochMicros, int picosOfMicro, ZoneId zoneId)
Formats a timestamp of the given precision. This method doesn't do any rounding, so it's expected that the combination of [epochMicros, picosSecond] is already rounded to the provided precision if necessary
-
formatTimestamp
public static String formatTimestamp(int precision, long epochMicros, int picosOfMicro, ZoneId zoneId, DateTimeFormatter yearToSecondFormatter)
Formats a timestamp of the given precision. This method doesn't do any rounding, so it's expected that the combination of [epochMicros, picosSecond] is already rounded to the provided precision if necessary
-
formatTimestampWithTimeZone
public static String formatTimestampWithTimeZone(int precision, long epochMillis, int picosOfMilli, ZoneId zoneId)
-
formatTimestamp
public static String formatTimestamp(int precision, LocalDateTime dateTime, long picoFraction, DateTimeFormatter yearToSecondFormatter, Consumer<StringBuilder> zoneIdFormatter)
-
parseTimestampWithTimeZone
public static Object parseTimestampWithTimeZone(int precision, String value)
-
timeHasTimeZone
public static boolean timeHasTimeZone(String value)
-
extractTimePrecision
public static int extractTimePrecision(String value)
-
parseTime
public static long parseTime(String value)
-
parseShortTimeWithTimeZone
public static long parseShortTimeWithTimeZone(String value)
-
parseLongTimeWithTimeZone
public static LongTimeWithTimeZone parseLongTimeWithTimeZone(String value)
-
longTimestamp
public static LongTimestamp longTimestamp(long precision, Instant start)
-
longTimestamp
public static LongTimestamp longTimestamp(long epochSecond, long fractionInPicos)
-
longTimestampWithTimeZone
public static LongTimestampWithTimeZone longTimestampWithTimeZone(long precision, Instant start, TimeZoneKey timeZoneKey)
-
longTimestampWithTimeZone
public static LongTimestampWithTimeZone longTimestampWithTimeZone(long epochSecond, long fractionInPicos, ZoneId zoneId)
-
roundToEpochMillis
public static long roundToEpochMillis(LongTimestampWithTimeZone timestamp)
-
calculateOffsetMinutes
public static int calculateOffsetMinutes(int sign, int offsetHour, int offsetMinute)
-
getOffsetMinutes
public static int getOffsetMinutes(Instant instant, TimeZoneKey zoneKey)
-
isValidOffset
public static boolean isValidOffset(int hour, int minute)
-
-