Package org.bson

Class BsonTimestamp

java.lang.Object
org.bson.BsonValue
org.bson.BsonTimestamp
All Implemented Interfaces:
Comparable<BsonTimestamp>

public final class BsonTimestamp extends BsonValue implements Comparable<BsonTimestamp>
A value representing the BSON timestamp type.
Since:
3.0
  • Constructor Details

    • BsonTimestamp

      public BsonTimestamp()
      Construct a new instance with a null time and a 0 increment.
    • BsonTimestamp

      public BsonTimestamp(long value)
      Construct a new instance for the given value, which combines the time in seconds and the increment as a single long value.
      Parameters:
      value - the timetamp as a single long value
      Since:
      3.5
    • BsonTimestamp

      public BsonTimestamp(int seconds, int increment)
      Construct a new instance for the given time and increment.
      Parameters:
      seconds - the number of seconds since the epoch
      increment - the increment.
  • Method Details

    • getBsonType

      public BsonType getBsonType()
      Description copied from class: BsonValue
      Gets the BSON type of this value.
      Specified by:
      getBsonType in class BsonValue
      Returns:
      the BSON type, which may not be null (but may be BSONType.NULL)
    • getValue

      public long getValue()
      Gets the value of the timestamp.
      Returns:
      the timestamp value
      Since:
      3.5
    • getTime

      public int getTime()
      Gets the time in seconds since epoch.
      Returns:
      an int representing time in seconds since epoch
    • getInc

      public int getInc()
      Gets the increment value.
      Returns:
      an incrementing ordinal for operations within a given second
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(BsonTimestamp ts)
      Specified by:
      compareTo in interface Comparable<BsonTimestamp>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object