Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:50:56+00:00 2026-05-28T01:50:56+00:00

I have a custom object whose structure is public String name; public int type;

  • 0

I have a custom object whose structure is

public String name;
public int type;
public String createdOn;

createdOn is date and its format is : 2011-12-16T23:27:27+0000

I have stored multiple objects of this type in ArrayList and now I want to sort them according to there creation date and time.

I have tried using Collections.sort(....) , but no suitable result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:50:57+00:00Added an answer on May 28, 2026 at 1:50 am

    Doing some R&D after getting answers, I solved the sorting thing, here is the code to sort array list by date.

    Collections.sort(arrlst,new Comparator<T>() {
    
                        public int compare(T lhs, T rhs) {
    
                            try {
                                SimpleDateFormat dateFormatlhs = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
                                Date convertedDatelhs = dateFormatlhs.parse(lhs.feedCreatedTime);
                                Calendar calendarlhs = Calendar.getInstance();
                                calendarlhs.setTime(convertedDatelhs);
    
                                SimpleDateFormat dateFormatrhs = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
                                Date convertedDaterhs = dateFormatrhs.parse(rhs.feedCreatedTime);
                                Calendar calendarrhs = Calendar.getInstance();
                                calendarrhs.setTime(convertedDaterhs);
    
                                if(calendarlhs.getTimeInMillis() > calendarrhs.getTimeInMillis())
                                {   
    
    
                                    return -1;
                                }
                                else
                                {
    
    
                                    return 1;
    
                                }
                            } catch (ParseException e) {
    
                                e.printStackTrace();
                            }
    
    
                            return 0;
                        }
                    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Page object whose uniqueness comes from its PageDomain . The schema
I have the following method: public IEnumerable<Foo> GetFoo(int x, string y) { return from
I have an AccountController whose constructor takes an object derived from my custom IOpenIdAuthentication
I have a custom object that implements INotifyPropertyChanged. I have a collection of these
I have a custom object Foo with a boolean property called Flagged and when
What I am attempting to do is the following: I have a custom object
I have a custom security principal object which I set in the global.asax for
I have a Repeater contol bound to a custom object (an EntitySpaces query) and
I've created a custom object, I have it appearing automatically on the Account details
I have a UITableView that displays various nsstrings from a custom object called a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.