Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Sorting an ArrayList<MyObject> by MyObject.getDate()

  1. #1
    Junior Member
    Join Date
    May 2012
    Thanked 0 Times in 0 Posts

    Default Sorting an ArrayList<MyObject> by MyObject.getDate()


    I'm attempting to SORT an ArrayList<MyObject> by (Type Date) MyObject.getDate()

    My format is formatted by SimpleDateFormat by dd-mm-yyyy;
    I'm using a custom comparator to sort my list.
    I'm using Collections.sort(produuctList, new CustomComparator())

    Problem my sorted list is only by dd and not dd-mm-yyyy.

    Any ideas?


    print prod list.jpg

  2. #2
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    In Hyrule enjoying a chat with Demise and Ganondorf
    My Mood
    Thanked 48 Times in 42 Posts

    Default Re: Sorting an ArrayList<MyObject> by MyObject.getDate()

    What is the code for your custom comparator? Does it take into account day, month, and year?
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!

    Wanna hear something funny?

    Me too.

Similar Threads

  1. Sorting an ArrayList
    By gatorsgirl in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 7th, 2012, 01:22 PM
  2. ArrayList Sorting Problem
    By coke32 in forum Object Oriented Programming
    Replies: 3
    Last Post: April 29th, 2012, 08:53 AM
  3. Sorting ArrayList
    By leao in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 31st, 2011, 03:33 PM
  4. Sorting a Arraylist
    By waterjames in forum Java Theory & Questions
    Replies: 1
    Last Post: November 26th, 2010, 02:47 PM
  5. NullPointerException when trying to read Strings into an array of myObject
    By sdivinyi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 24th, 2010, 09:45 AM