Package com.streambase.sb
Class Timestamp
java.lang.Object
com.streambase.sb.Timestamp
- All Implemented Interfaces:
Serializable,Comparable<Timestamp>
This class represents a Streambase Timestamp. The timestamp can be of two
different types: An interval or an offset since the epoch, January 1, 1970
00:00:00.000 GMT (Gregorian).
Note: Serializations of instances of this class that are created
(e.g., by using ObjectOutputStream) in one version of
StreamBase in general will not be deserializable in any other version of
StreamBase.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFor use denoting timestamps objects between timestamp and interval types. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default format for date and time formatting and parsing used by StreamBase: "yyyy-MM-dd HH:mm:ss.SSSZ"static final StringThe default format for date and time formatting and parsing used by StreamBase when the timezone is to be ignored: "yyyy-MM-dd HH:mm:ss.SSS"static final longDeprecated.TimestampType now handles the enumeration.static final DecimalFormatFormat of a timestamp intervalstatic final longDeprecated.TimestampType now handles the enumeration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TimestampfromString(CharSequence dateString) Create a timestamp using the given stringstatic TimestampfromString(String dateString) Create a timestamp using the given stringstatic TimestampfromString(String dateString, com.streambase.sb.util.CSV.FormatInfo format) Create a timestamp using the given string and format.getType()Return the current type of timestampbooleanReturns true if this is an interval timestamp; false otherwisestatic Timestampmsecs(long timeVal) Create a timestamp using only a timeValstatic Timestampmsecs(long type, double ms) Deprecated.TimestampType type enum replaces use of long type.static Timestampmsecs(long type, long ms) Deprecated.TimestampType type enum replaces use of long type.static Timestampmsecs(Timestamp.Type type, double ms) Create a timestamp using the following type and # of millisecondsstatic Timestampmsecs(Timestamp.Type type, long ms) Create a timestamp using the following type and # of millisecondsstatic Timestampnow()Create a timestamp using the current timestatic Timestampsecs(long type, double secs) Deprecated.TimestampType type enum replaces use of long type.static Timestampsecs(long type, long secs) Deprecated.TimestampType type enum replaces use of long type.static Timestampsecs(Timestamp.Type type, double secs) Create a timestamp using the following type and # of secondsstatic Timestampsecs(Timestamp.Type type, long secs) Create a timestamp using the following type and # of secondstoDate()Create a java.util.DatelongtoMsecs()Return the # of milliseconds since the epoch or in the intervallongtoSecs()Return the # of seconds since the epoch or in the intervalCreate a java.sql.DateCreate a java.sql.TimestamptoString()Create string representation of this timestamp with the timezonetoString(boolean includeTimezone) Create string representation of this timestamp, optionally include timezone
-
Field Details
-
TIMESTAMP
Deprecated.TimestampType now handles the enumeration.Timestamps can be timestamps or intervals. TIMESTAMP indicates that this is a TIMESTAMP -
INTERVAL
Deprecated.TimestampType now handles the enumeration.Timestamps can be timestamps or intervals. INTERVAL indicates that this is an INTERVAL -
INTERVAL_FORMAT
Format of a timestamp interval -
DATE_FORMAT
The default format for date and time formatting and parsing used by StreamBase: "yyyy-MM-dd HH:mm:ss.SSSZ"- See Also:
-
DATE_FORMAT_NO_TIMEZONE
The default format for date and time formatting and parsing used by StreamBase when the timezone is to be ignored: "yyyy-MM-dd HH:mm:ss.SSS"- See Also:
-
-
Constructor Details
-
Timestamp
Create a Timestamp out of a java.util.Date- Parameters:
date- a java.util.date
-
-
Method Details
-
msecs
Create a timestamp using only a timeVal- Parameters:
timeVal- a long representation of a timeVal structure, with the type in the least significant bit.- Returns:
- the Timestamp
-
msecs
Create a timestamp using the following type and # of milliseconds- Parameters:
type- eitherTimestamp.Type.INTERVALorTimestamp.Type.TIMESTAMPms- An instant in time represented by a millisecond value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- the Timestamp
-
msecs
Deprecated.TimestampType type enum replaces use of long type.Create a timestamp using the following type and # of milliseconds- Parameters:
type- either INTERVAL (0) or TIMESTAMP (1)ms- An instant in time represented by a millisecond value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- timestamp
-
msecs
Create a timestamp using the following type and # of milliseconds- Parameters:
type- eitherTimestamp.Type.INTERVALorTimestamp.Type.TIMESTAMPms- An instant in time represented by a millisecond value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- the Timestamp
-
msecs
Deprecated.TimestampType type enum replaces use of long type.Create a timestamp using the following type and # of milliseconds- Parameters:
type- either INTERVAL (0) or TIMESTAMP (1)ms- An instant in time represented by a millisecond value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- the Timestamp
-
secs
Create a timestamp using the following type and # of seconds- Parameters:
type- eitherTimestamp.Type.INTERVALorTimestamp.Type.TIMESTAMPsecs- An instant in time represented by a second value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- the Timestamp
-
secs
Deprecated.TimestampType type enum replaces use of long type.Create a timestamp using the following type and # of seconds- Parameters:
type- either INTERVAL (0) or TIMESTAMP (1)secs- An instant in time represented by a second value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- the Timestamp
-
secs
Create a timestamp using the following type and # of seconds- Parameters:
type- eitherTimestamp.Type.INTERVALorTimestamp.Type.TIMESTAMPsecs- An instant in time represented by a second value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- the Timestamp
-
secs
Deprecated.TimestampType type enum replaces use of long type.Create a timestamp using the following type and # of seconds- Parameters:
type- either INTERVAL (0) or TIMESTAMP (1)secs- An instant in time represented by a second value that is an offset from the Epoch, January 1, 1970 00:00:00.000 GMT (Gregorian).- Returns:
- the Timestamp
-
now
-
fromString
Create a timestamp using the given string- Parameters:
dateString- string containing a date/time, or an interval. date/time format: "YYYY-MM-DD HH:MM:SS.SSS+TTTT". For example, "2005-01-07 11:09:37.000-0500" where -0500 indicates Eastern Standard Time. The timezone is optional, as are the fractional seconds. Interval format: "SS.SSS", seconds and fractional seconds- Returns:
- the Timestamp
- Throws:
StreamBaseException- when unable to parse as a timestamp- Since:
- 6.5
-
fromString
Create a timestamp using the given string- Parameters:
dateString- string containing a date/time, or an interval. date/time format: "YYYY-MM-DD HH:MM:SS.SSS+TTTT". For example, "2005-01-07 11:09:37.000-0500" where -0500 indicates Eastern Standard Time. The timezone is optional, as are the fractional seconds. Interval format: "SS.SSS", seconds and fractional seconds- Returns:
- the Timestamp
- Throws:
StreamBaseException- when unable to parse as a timestamp
-
fromString
public static Timestamp fromString(String dateString, com.streambase.sb.util.CSV.FormatInfo format) throws StreamBaseException Create a timestamp using the given string and format. Assumption: If format is present, the dateString may not represent an interval- Parameters:
dateString- Date stringformat- Format- Returns:
- a timestamp Timestamp value
- Throws:
StreamBaseException- Error creating timestamp
-
isInterval
public boolean isInterval()Returns true if this is an interval timestamp; false otherwise- Returns:
- true if an interval type
-
getType
Return the current type of timestamp- Returns:
- the current type of the timestamp (INTERVAL or TIMESTAMP)
-
toDate
-
toSQLDate
-
toSQLTimestamp
-
toMsecs
public long toMsecs()Return the # of milliseconds since the epoch or in the interval- Returns:
- Milliseconds
-
toSecs
public long toSecs()Return the # of seconds since the epoch or in the interval- Returns:
- Seconds
-
toString
Create string representation of this timestamp, optionally include timezone- Parameters:
includeTimezone- include the timezone?- Returns:
- String representaion of this timestamp
-
toString
-