I have some lists that contain elements of type DataTime( Joda-time ). How can I sort them by date?
It will be great if somebody gave link to the example…
I have some lists that contain elements of type DataTime( Joda-time ). How can
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because the objects of your list implement the
Comparableinterface, you can usewhere
listis yourArrayList.Relevant Javadocs:
CollectionsDateTimeComparableEdit: If you want to sort a list of a custom class that contains a
DateTimefield in a similar way, you would have to implement theComparableinterface yourself. For example,Now, if you had a
ListofProfileinstances, you could employ the same method as above, namelyCollections.sort(list)wherelistis the list ofProfiles.