public class ObjectId extends Object implements Comparable<ObjectId>, Serializable
A globally unique identifier for objects.
Consists of 12 bytes, divided as follows:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| time | machine | pid | inc | ||||||||
Instances of this class are immutable.
| 构造器和说明 |
|---|
ObjectId()
Create a new object id.
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
compareTo(ObjectId id) |
boolean |
equals(Object o) |
static ObjectId |
get()
Gets a new object id.
|
static int |
getCurrentCounter()
Gets the current value of the auto-incrementing counter.
|
Date |
getDate()
Gets the timestamp as a
Date instance. |
int |
getTimestamp()
Gets the timestamp (number of seconds since the Unix epoch).
|
int |
hashCode() |
static String |
id()
生成新id
|
static boolean |
isValid(String s)
Checks if a string could be an
ObjectId. |
static void |
main(String[] args) |
byte[] |
toByteArray()
Convert to a byte array.
|
String |
toHexString()
Converts this instance into a 24-byte hexadecimal string representation.
|
public static String id()
public static ObjectId get()
public static boolean isValid(String s)
ObjectId.s - a potential ObjectId as a String.IllegalArgumentException - if hexString is nullpublic String toHexString()
public byte[] toByteArray()
public int compareTo(ObjectId id)
compareTo 在接口中 Comparable<ObjectId>public int getTimestamp()
public Date getDate()
Date instance.public static int getCurrentCounter()
public static void main(String[] args)
Copyright © 2020. All rights reserved.