Mongodb Object_id in Spring boot

Viewed 796

I have a spring boot application with mongo database. I created the entity so that the id of the document is stored as an Object_id.

@Document(collection = "projects")
public class Project {

@Id
private String id;

private String name;

}

Now i want to get timestamp and the id string from mongo object_id. Can this be done in spring boot ?

1 Answers

org.bson.types.ObjectId has 2 methods : getTimeSecond() and getTime()

Related