Package org.teiid.transport.pg
Class TimestampUtils
- java.lang.Object
-
- org.teiid.transport.pg.TimestampUtils
-
public class TimestampUtils extends Object
Slimmed down from org.postgresql.jdbc2.TimestampUtils
-
-
Field Summary
Fields Modifier and Type Field Description static longDATE_NEGATIVE_INFINITYstatic longDATE_NEGATIVE_SMALLER_INFINITYstatic longDATE_POSITIVE_INFINITYstatic longDATE_POSITIVE_SMALLER_INFINITY
-
Constructor Summary
Constructors Constructor Description TimestampUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TimeconvertToTime(long millis, TimeZone tz)Extracts the time part from a timestamp.static DatetoDate(TimeZone tz, int days)Returns the SQL Date object given the timezone and number of daysstatic longtoPgSecs(long secs)Converts the given java seconds to postgresql seconds.static TimestamptoTimestamp(long time, TimeZone tz)
-
-
-
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
-
-
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. SeetoJavaSecs(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 microsecondstz-- 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.
-
-