public class Timestamp extends java.lang.Object implements java.lang.Comparable<Timestamp>, java.io.Serializable
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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATE_FORMAT
The default format for date and time formatting and parsing used by StreamBase:
"yyyy-MM-dd HH:mm:ss.SSSZ"
|
static java.lang.String |
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"
|
static long |
INTERVAL
Timestamps can be timestamps or intervals.
|
static com.ibm.icu.text.DecimalFormat |
INTERVAL_FORMAT |
static long |
TIMESTAMP
Timestamps can be timestamps or intervals.
|
Constructor and Description |
---|
Timestamp(java.util.Date date)
Create a Timestamp out of a java.util.Date
|
Modifier and Type | Method and Description |
---|---|
static Timestamp |
fromString(java.lang.CharSequence dateString)
Create a timestamp using the given string
|
static Timestamp |
fromString(java.lang.String dateString)
Create a timestamp using the given string
|
static Timestamp |
fromString(java.lang.String dateString,
com.streambase.sb.util.CSV.FormatInfo format)
Create a timestamp using the given string and format.
|
long |
getType()
Return the current type of timestamp
|
boolean |
isInterval()
Returns true if this is an interval timestamp; false otherwise
|
static Timestamp |
msecs(long type,
double ms)
Create a timestamp using the following type and # of milliseconds
|
static Timestamp |
msecs(long type,
long ms)
Create a timestamp using the following type and # of milliseconds
|
static Timestamp |
now()
Create a timestamp using the current time
|
static Timestamp |
secs(long type,
double secs)
Create a timestamp using the following type and # of seconds
|
static Timestamp |
secs(long type,
long secs)
Create a timestamp using the following type and # of seconds
|
java.util.Date |
toDate()
Create a java.util.Date
|
long |
toMsecs()
Return the # of milliseconds since the epoch or in the interval
|
long |
toSecs()
Return the # of seconds since the epoch or in the interval
|
java.sql.Date |
toSQLDate()
Create a java.sql.Date
|
java.sql.Timestamp |
toSQLTimestamp()
Create a java.sql.Timestamp
|
java.lang.String |
toString()
Create string representation of this timestamp with the timezone
|
java.lang.String |
toString(boolean includeTimezone)
Create string representation of this timestamp, optionally include timezone
|
public static final long TIMESTAMP
public static final long INTERVAL
public static final com.ibm.icu.text.DecimalFormat INTERVAL_FORMAT
public static final java.lang.String DATE_FORMAT
public static final java.lang.String DATE_FORMAT_NO_TIMEZONE
public Timestamp(java.util.Date date)
date
- a java.util.datepublic static Timestamp msecs(long type, long ms)
type
- either INTERVAL or 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).public static Timestamp msecs(long type, double ms)
type
- either INTERVAL or 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).public static Timestamp secs(long type, long secs)
type
- either INTERVAL or 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).public static Timestamp secs(long type, double secs)
type
- either INTERVAL or 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).public static Timestamp now()
public static Timestamp fromString(java.lang.CharSequence dateString) throws StreamBaseException
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 secondsStreamBaseException
- when unable to parse as a timestamppublic static Timestamp fromString(java.lang.String dateString) throws StreamBaseException
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 secondsStreamBaseException
- when unable to parse as a timestamppublic static Timestamp fromString(java.lang.String dateString, com.streambase.sb.util.CSV.FormatInfo format) throws StreamBaseException
dateString
- format
- StreamBaseException
public boolean isInterval()
public long getType()
public java.util.Date toDate()
public java.sql.Date toSQLDate()
public java.sql.Timestamp toSQLTimestamp()
public long toMsecs()
public long toSecs()
public java.lang.String toString(boolean includeTimezone)
includeTimezone
- include the timezone?public java.lang.String toString()
toString
in class java.lang.Object