Package org.voltdb.types
Class TimestampType
java.lang.Object
org.voltdb.types.TimestampType
- All Implemented Interfaces:
- Comparable<TimestampType>,- org.json_voltpatches.JSONString
public class TimestampType
extends Object
implements org.json_voltpatches.JSONString, Comparable<TimestampType>
Represent a microsecond-accurate VoltDB timestamp type.
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a TimestampType instance for the current time.TimestampType(long timestamp) Create a TimestampType from microseconds from epoch.TimestampType(String param) Construct from a timestamp string in a complete date or time format.TimestampType(Date date) Create a TimestampType from a Java Date class.
- 
Method SummaryModifier and TypeMethodDescriptionRetrieve a copy of the approximate Java date.org.voltdb.types.DateTypeRetrieve a properly typed copy of the VoltDB Date for the VoltDB TimeStamp's year, month and day values.Retrieve a copy of the Java date for a TimeStamp with millisecond granularity.Retrieve a properly typed copy of the Java date for a TimeStamp with millisecond granularity.Retrieve a properly typed copy of the Java Timestamp for the VoltDB TimeStamp.intcompareTo(TimestampType dateval) CompareTo - to mimic Java DatebooleanEquality.longgetTime()Read the microsecond in time stored by this timestamp.shortgetUSec()Get the microsecond portion of this timestampinthashCode()Hashcode with the same uniqueness as a Java Date.static longmillisFromJDBCformat(String param) Given a string parseable by the JDBC Timestamp parser, return the fractional component in milliseconds.toString()An implementation of toString for debugging and printing VoltTables.An implementation of toString for debugging and printing VoltTables which allows the specification of a timezone.
- 
Constructor Details- 
TimestampTypepublic TimestampType(long timestamp) Create a TimestampType from microseconds from epoch.- Parameters:
- timestamp- microseconds since epoch.
 
- 
TimestampTypeCreate a TimestampType from a Java Date class. Microseconds will be rounded to zero.- Parameters:
- date- Java Date instance.
 
- 
TimestampTypeConstruct from a timestamp string in a complete date or time format. This is typically used for reading CSV data or data output fromTimestamp's string format.- Parameters:
- param- A string in one of these formats: "YYYY-MM-DD", "YYYY-MM-DD HH:MM:SS", OR "YYYY-MM-DD HH:MM:SS.sss" with sss allowed to be from 0 up to 6 significant digits.
 
- 
TimestampTypepublic TimestampType()Create a TimestampType instance for the current time.
 
- 
- 
Method Details- 
millisFromJDBCformatGiven a string parseable by the JDBC Timestamp parser, return the fractional component in milliseconds.- Parameters:
- param- A timstamp in string format that is parseable by JDBC.
- Returns:
- The fraction of a second portion of this timestamp expressed in milliseconds.
- Throws:
- IllegalArgumentException- if the timestamp uses higher than millisecond precision.
 
- 
getTimepublic long getTime()Read the microsecond in time stored by this timestamp.- Returns:
- microseconds
 
- 
getUSecpublic short getUSec()Get the microsecond portion of this timestamp- Returns:
- Microsecond portion of timestamp as a short
 
- 
equalsEquality.
- 
toStringAn implementation of toString for debugging and printing VoltTables. This formats the timestamp value using a standard ODBC date format, similar to ISO-8601. The format is yyyy-MM-dd HH:mm:ss.SSSSSS. Here, unlike the Java SimpleDateFormat formatter, the SSSSSS part is the number of microseconds. The timezone is the default timezone of the JVM. This will be the timezone of the application, which may not match the timezone of the database server. See the overload of this function which accepts a time zone for more control over the specification of the timezone.
- 
toStringAn implementation of toString for debugging and printing VoltTables which allows the specification of a timezone.- Parameters:
- zone- Desired timezone.
- Returns:
- A string with the time in ODBC format with the desired timezone.
 
- 
hashCodepublic int hashCode()Hashcode with the same uniqueness as a Java Date.
- 
compareToCompareTo - to mimic Java Date- Specified by:
- compareToin interface- Comparable<TimestampType>
 
- 
asApproximateJavaDateRetrieve a copy of the approximate Java date. The returned date is a copy; this object will not be affected by modifications of the returned instance.- Returns:
- Clone of underlying Date object.
 
- 
asExactJavaDateRetrieve a copy of the Java date for a TimeStamp with millisecond granularity. The returned date is a copy; this object will not be affected by modifications of the returned instance.- Returns:
- Clone of underlying Date object.
 
- 
asExactJavaSqlDateRetrieve a properly typed copy of the Java date for a TimeStamp with millisecond granularity. The returned date is a copy; this object will not be affected by modifications of the returned instance.- Returns:
- specifically typed copy of underlying Date object.
 
- 
asJavaTimestampRetrieve a properly typed copy of the Java Timestamp for the VoltDB TimeStamp. The returned Timestamp is a copy; this object will not be affected by modifications of the returned instance.- Returns:
- reformatted Timestamp expressed internally as 1000s of nanoseconds.
 
- 
asDateTypepublic org.voltdb.types.DateType asDateType()Retrieve a properly typed copy of the VoltDB Date for the VoltDB TimeStamp's year, month and day values. The returned object is an immutable copy; this object will not be affected by modifications of the returned instance.- Returns:
- VoltDB Date part from the original VoltDB TimeStamp.
 
- 
toJSONString- Specified by:
- toJSONStringin interface- org.json_voltpatches.JSONString
 
 
-