Class DateTimeFormatterUtil
- java.lang.Object
-
- com.amazonaws.athena.connector.lambda.data.DateTimeFormatterUtil
-
public class DateTimeFormatterUtil extends Object
Provides utility methods relating to formatting strings to date/datetime type
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ChronoUnit
arrowTimeUnitToChronoUnit(org.apache.arrow.vector.types.TimeUnit timeunit)
static LocalDate
bigDecimalToLocalDate(BigDecimal value, ZoneId defaultTimeZone)
Transforms big decimal value to LocalDate using the provided default formatstatic LocalDateTime
bigDecimalToLocalDateTime(BigDecimal value, ZoneId defaultTimeZone)
Transforms big decimal value to LocalDateTime using the provided default formatstatic ZonedDateTime
constructZonedDateTime(long epochTimestamp, org.apache.arrow.vector.types.pojo.ArrowType.Timestamp arrowType)
Reconstruct a ZonedDateTime given an epoch timestamp and its arrow typestatic void
disableTimezonePacking()
static String
inferDateTimeFormat(String value)
Infers the date format to be used for the values in that column by passing through an array of supported formats this is then cached in DDDBRecordMetadata and reused so that the values in the same column does not have to be re-evaluated/parsedstatic Object
stringToDateTime(String value, String dateFormat, ZoneId defaultTimeZone)
Transforms the raw string to LocalDateTime using the provided default formatstatic LocalDate
stringToLocalDate(String value, String dateFormat, ZoneId defaultTimeZone)
Transforms the raw string to LocalDate using the provided default formatstatic Object
stringToZonedDateTime(String value, String dateFormat, ZoneId defaultTimeZone)
Tries to parse the string value to ZonedDateTime, If fails, then falls back to the LocalDateTime with default zonestatic org.apache.arrow.vector.holders.TimeStampMicroTZHolder
timestampMicroTzHolderFromObject(Object value, String targetTimeZoneId)
static org.apache.arrow.vector.holders.TimeStampMilliTZHolder
timestampMilliTzHolderFromObject(Object value, String targetTimeZoneId)
static ZonedDateTime
zonedDateTimeFromObject(Object value)
-
-
-
Method Detail
-
disableTimezonePacking
public static void disableTimezonePacking()
-
stringToLocalDate
public static LocalDate stringToLocalDate(String value, String dateFormat, ZoneId defaultTimeZone)
Transforms the raw string to LocalDate using the provided default format- Parameters:
value
- raw value to be transformed to LocalDatedateFormat
- customer specified or inferred dateformatdefaultTimeZone
- default timezone to be applied- Returns:
- LocalDate object parsed from value
-
stringToZonedDateTime
public static Object stringToZonedDateTime(String value, String dateFormat, ZoneId defaultTimeZone)
Tries to parse the string value to ZonedDateTime, If fails, then falls back to the LocalDateTime with default zone- Parameters:
value
- raw value to be transformed to LocalDateTimedateFormat
- customer specified or inferred dateformatdefaultTimeZone
- default timezone to be applied- Returns:
- LocalDateTime or ZonedDateTime object parsed from value
-
stringToDateTime
public static Object stringToDateTime(String value, String dateFormat, ZoneId defaultTimeZone)
Transforms the raw string to LocalDateTime using the provided default format- Parameters:
value
- raw value to be transformed to LocalDateTimedateFormat
- customer specified or inferred dateformatdefaultTimeZone
- default timezone to be applied- Returns:
- LocalDateTime or ZonedDateTime object parsed from value
-
bigDecimalToLocalDate
public static LocalDate bigDecimalToLocalDate(BigDecimal value, ZoneId defaultTimeZone)
Transforms big decimal value to LocalDate using the provided default format- Parameters:
value
- raw value to be transformed to LocalDatedefaultTimeZone
- default timezone to be applied- Returns:
- LocalDate object parsed from value
-
bigDecimalToLocalDateTime
public static LocalDateTime bigDecimalToLocalDateTime(BigDecimal value, ZoneId defaultTimeZone)
Transforms big decimal value to LocalDateTime using the provided default format- Parameters:
value
- raw value to be transformed to LocalDateTimedefaultTimeZone
- default timezone to be applied- Returns:
- LocalDateTime object parsed from value
-
inferDateTimeFormat
public static String inferDateTimeFormat(String value)
Infers the date format to be used for the values in that column by passing through an array of supported formats this is then cached in DDDBRecordMetadata and reused so that the values in the same column does not have to be re-evaluated/parsed- Parameters:
value
- string value to infer a date time format from- Returns:
- string representing the datetime format null if it does not match any of the supported formats
-
constructZonedDateTime
public static ZonedDateTime constructZonedDateTime(long epochTimestamp, org.apache.arrow.vector.types.pojo.ArrowType.Timestamp arrowType)
Reconstruct a ZonedDateTime given an epoch timestamp and its arrow type- Parameters:
epochTimestamp
- this is the timestamp in epoch time. Possibly in packed form, where it contains the timezone.arrowType
- this is the arrowType that the value being passed in came from. The arrow type contains information about the units and timezone.- Returns:
- ZonedDateTime the converted ZonedDateTime from the epochUtc timestamp and timezone either from the packed value or arrowType.
-
arrowTimeUnitToChronoUnit
public static ChronoUnit arrowTimeUnitToChronoUnit(org.apache.arrow.vector.types.TimeUnit timeunit)
-
zonedDateTimeFromObject
public static ZonedDateTime zonedDateTimeFromObject(Object value)
-
timestampMilliTzHolderFromObject
public static org.apache.arrow.vector.holders.TimeStampMilliTZHolder timestampMilliTzHolderFromObject(Object value, String targetTimeZoneId)
-
-