Class TimestampUtils


  • public class TimestampUtils
    extends Object
    Slimmed down from org.postgresql.jdbc2.TimestampUtils
    • Field Detail

      • DATE_POSITIVE_INFINITY

        public static final long DATE_POSITIVE_INFINITY
        See Also:
        Constant Field Values
      • DATE_NEGATIVE_INFINITY

        public static final long DATE_NEGATIVE_INFINITY
        See Also:
        Constant Field Values
      • DATE_POSITIVE_SMALLER_INFINITY

        public static final long DATE_POSITIVE_SMALLER_INFINITY
        See Also:
        Constant Field Values
      • DATE_NEGATIVE_SMALLER_INFINITY

        public static final long DATE_NEGATIVE_SMALLER_INFINITY
        See Also:
        Constant Field Values
    • Constructor Detail

      • TimestampUtils

        public TimestampUtils()
    • Method Detail

      • toDate

        public static Date toDate​(TimeZone tz,
                                  int days)
        Returns the SQL Date object given the timezone and number of days
        Parameters:
        tz - The timezone used.
        Returns:
        The parsed date object.
      • toPgSecs

        public static long toPgSecs​(long secs)
        Converts the given java seconds to postgresql seconds. See toJavaSecs(long) for the reverse operation. The conversion is valid for any year 100 BC onwards.
        Parameters:
        secs - Postgresql seconds.
        Returns:
        Java seconds.
      • toTimestamp

        public static Timestamp toTimestamp​(long time,
                                            TimeZone tz)
        Parameters:
        time - in microseconds
        tz -
        Returns:
      • convertToTime

        public static Time convertToTime​(long millis,
                                         TimeZone tz)
        Extracts the time part from a timestamp. This method ensures the date part of output timestamp looks like 1970-01-01 in given timezone.
        Parameters:
        millis - The timestamp from which to extract the time.
        tz - timezone to use.
        Returns:
        The extracted time.