Skip navigation links
org.bson.types

Class BSONTimestamp

    • Constructor Detail

      • BSONTimestamp

        public BSONTimestamp()
        Construct an empty BSONTimestamp.
      • BSONTimestamp

        public BSONTimestamp(Date date)
        Construct BSONTimestamp by java.util.Date.
      • BSONTimestamp

        public BSONTimestamp(int time,
                             int inc)
        Construct BSONTimestamp.
        Parameters:
        time - seconds since epoch.
        inc - microseconds in range of [0us, 999999us], while the 'inc' is out of range, the carry will occur.
      • BSONTimestamp

        public BSONTimestamp(Timestamp timestamp)
        Construct BSONTimestamp by java.sql.Timestamp. The precision of BSONTimestamp is microsecond and Timestamp is nanosecond, so there may have a loss of nanoseconds.
    • Method Detail

      • getDate

        public Date getDate()
        Returns:
        get time in seconds since epoch
      • getInc

        public int getInc()
        Returns:
        get time in microseconds since epoch
      • getTime

        public int getTime()
        Returns:
        get time in seconds since epoch
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toDate

        public Date toDate()
        Returns:
        Date of time and inc in milliseconds since epoch.
      • toTimestamp

        public Timestamp toTimestamp()
        Returns:
        Timestamp of time in milliseconds and inc in nanoseconds since epoch

Copyright © 2023. All rights reserved.