Class DateTimeFormatterUtil


  • public class DateTimeFormatterUtil
    extends Object
    Provides utility methods relating to formatting strings to date/datetime type
    • 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 LocalDate
        dateFormat - customer specified or inferred dateformat
        defaultTimeZone - 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 LocalDateTime
        dateFormat - customer specified or inferred dateformat
        defaultTimeZone - 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 LocalDateTime
        dateFormat - customer specified or inferred dateformat
        defaultTimeZone - 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 LocalDate
        defaultTimeZone - 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 LocalDateTime
        defaultTimeZone - 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)
      • timestampMicroTzHolderFromObject

        public static org.apache.arrow.vector.holders.TimeStampMicroTZHolder timestampMicroTzHolderFromObject​(Object value,
                                                                                                              String targetTimeZoneId)