2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

retive data order by date using java from mongodb

I have a collection of document where i want to retrieve data order by date using java code. How can i do?
userimage

try as below:


MongoCursor<Document> mongoCursor = mongoCollection.find().sort(new Document("KeyNAME", -1)).iterator();


Will give you data with descending order.

Answer is