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 6588003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:59:30+00:00 2026-05-25T16:59:30+00:00

I have a problem that I want to Sort the String Arraylist of Dates

  • 0

I have a problem that I want to Sort the String Arraylist of Dates with format= 2011-07-18T10:39:31.855Z with the help of Date formatter in java. But don’t know how to do that? Can any one tell me How to use Date formatter with custom format for sorting of data?

Please help me out about this problem.

Thanks in advance.

  • 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-25T16:59:30+00:00Added an answer on May 25, 2026 at 4:59 pm

    Since you mention in your question that you already have an ArrayList of Strings, and you show that the strings are all dates that are already formatted in ISO8601, your task is very simple: just sort the arraylist as-is.

    That is one of the many benefits of ISO8601!

    From Wikipedia:

    Date and time values are organized from the most to the least significant: year, month (or week), day, hour, minute, second, and fraction of second. The lexicographical order of the representation thus corresponds to chronological order, except for date representations involving negative years. This allows dates to be naturally sorted by, for example, file systems.

    In more detail:

    List<String> dateStrings = Arrays.asList(
        "2011-07-18T10:39:31.855Z",
        "2012-09-18T10:19:31.855Z",
        "2011-07-18T10:39:31.055Z",
        "1903-12-01T00:39:31Z",
    );
    Arrays.sort(dateStrings);
    // now dateStrings is sorted by date.
    

    Again the idea here is that you do not have to convert the strings to dates to do the sort.

    As an aside, if your list contained actual Date objects, you can also just call Arrays.sort and your list would get sorted properly as well, because dates are comparable in Java. But your question asked about strings, and strings in ISO8601 at that, so if this was an important part of your problem you might as well take advantage of that benefit of the format. TL;DR you don’t need a dateformat to sort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

with my RCP program I have the problem that I want to have more
My problem is that I want to have a tab bar view with its
I have a problem with my site. I want that the shadow stops at
I have problem with fancybox. I want to write a function that will run
I have a class that i want to push_back into a deque. The problem
My problem is simple: I have a long list of elements that I want
I have a big problem. I want to extract text from html table that
I have a 2D-array that I want to sort based on the second column.
I have a xml and I want to sort it by date.my code till
I have a ListView (GridView) that I want to sort by 2 columns, so

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.