com.streambase.sb

## Class Timestamp

- java.lang.Object
- - com.streambase.sb.Timestamp

- All Implemented Interfaces:
    Serializable, Comparable<Timestamp>

      public class Timestamp
      extends Object
      implements Comparable<Timestamp>, Serializable

  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:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DATE_FORMAT` The default format for date and time formatting and parsing used by StreamBase: "yyyy-MM-dd HH:mm:ss.SSSZ"
    `static 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 Summary

    Constructors
    Constructor and Description
    `Timestamp(Date date)` Create a Timestamp out of a java.util.Date

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Timestamp` | `fromString(CharSequence dateString)` Create a timestamp using the given string
    `static Timestamp` | `fromString(String dateString)` Create a timestamp using the given string
    `static Timestamp` | `fromString(String dateString, 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
    `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
    `Date` | `toSQLDate()` Create a java.sql.Date
    `Timestamp` | `toSQLTimestamp()` Create a java.sql.Timestamp
    `String` | `toString()` Create string representation of this timestamp with the timezone
    `String` | `toString(boolean includeTimezone)` Create string representation of this timestamp, optionally include timezone

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

- - ### Field Detail

    - #### TIMESTAMP

          public static final long TIMESTAMP

      Timestamps can be timestamps or intervals. TIMESTAMP indicates that this is a TIMESTAMP
      See Also:
        Constant Field Values

    - #### INTERVAL

          public static final long INTERVAL

      Timestamps can be timestamps or intervals. INTERVAL indicates that this is an INTERVAL
      See Also:
        Constant Field Values

    - #### INTERVAL_FORMAT

          public static final com.ibm.icu.text.DecimalFormat INTERVAL_FORMAT

    - #### DATE_FORMAT

          public static final String DATE_FORMAT

      The default format for date and time formatting and parsing used by StreamBase: "yyyy-MM-dd HH:mm:ss.SSSZ"
      See Also:
        Constant Field Values

    - #### DATE_FORMAT_NO_TIMEZONE

          public static final 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"
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Timestamp

          public Timestamp(Date date)

      Create a Timestamp out of a java.util.Date
      Parameters:
        `date` - a java.util.date

  - ### Method Detail

    - #### msecs

          public static Timestamp msecs(long type,
                                        long ms)

      Create a timestamp using the following type and # of milliseconds
      Parameters:
        `type` - either INTERVAL or TIMESTAMP
        `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

    - #### msecs

          public static Timestamp msecs(long type,
                                        double ms)

      Create a timestamp using the following type and # of milliseconds
      Parameters:
        `type` - either INTERVAL or TIMESTAMP
        `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

          public static Timestamp secs(long type,
                                       long secs)

      Create a timestamp using the following type and # of seconds
      Parameters:
        `type` - either INTERVAL or TIMESTAMP
        `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

          public static Timestamp secs(long type,
                                       double secs)

      Create a timestamp using the following type and # of seconds
      Parameters:
        `type` - either INTERVAL or TIMESTAMP
        `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

          public static Timestamp now()

      Create a timestamp using the current time
      Returns:
        the Timestamp

    - #### fromString

          public static Timestamp fromString(CharSequence dateString)
                                      throws StreamBaseException

      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

          public static Timestamp fromString(String dateString)
                                      throws StreamBaseException

      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,
                                             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` -
        `format` -
      Returns:
        a timestamp
      Throws:
        `StreamBaseException`

    - #### isInterval

          public boolean isInterval()

      Returns true if this is an interval timestamp; false otherwise

    - #### getType

          public long getType()

      Return the current type of timestamp
      Returns:
        the current type of the timestamp (INTERVAL or TIMESTAMP)

    - #### toDate

          public Date toDate()

      Create a java.util.Date
      Returns:
        a java.util.Date

    - #### toSQLDate

          public Date toSQLDate()

      Create a java.sql.Date
      Returns:
        a java.sql.Date

    - #### toSQLTimestamp

          public Timestamp toSQLTimestamp()

      Create a java.sql.Timestamp
      Returns:
        a java.sql.Timestamp

    - #### toMsecs

          public long toMsecs()

      Return the # of milliseconds since the epoch or in the interval

    - #### toSecs

          public long toSecs()

      Return the # of seconds since the epoch or in the interval

    - #### toString

          public String toString(boolean includeTimezone)

      Create string representation of this timestamp, optionally include timezone
      Parameters:
        `includeTimezone` - include the timezone?
      Returns:
        String representaion of this timestamp

    - #### toString

          public String toString()

      Create string representation of this timestamp with the timezone
      Overrides:
        `toString` in class `Object`
      Returns:
        String representaion of this timestamp

Copyright © 2015–2018 Cloud Software Group, Inc.. All rights reserved.