Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How can you sort dates?

Answer Posted / nitesh

Right now two ways come to my mind.

First:
Create a TreeSet, add all the dates to it. They get
sorted by default since java.util.Date implements
comparable. Here is an example -->
Set<Date> sortedDates = new TreeSet<Date>();
sortedDates.add(new Date());
Calendar cal = Calendar.getInstance();
cal.set(2009, 2, 12);
sortedDates.add(cal.getTime());

Second:
We can use the compare method inside Date class
directly and write our own sorting implementation.

Is This Answer Correct ?    11 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of static methods?

1043


What comes to mind when someone mentions a shallow copy in java?

1113


What differences exist between iterator and listiterator?

1049


Describe different states of a thread.

1007


What is hash table in java?

1034


What is the arraylist in java?

1061


What is a blocking method in Java?

1252


What are bind parameters?

1059


How is final different from finally and finalize?

930


Give us a program to check for parenthesis matching using stack.

1013


What is java abstraction with example?

1072


Can I learn java without any programming experience?

1047


What is the inheritance?

980


What is flush buffer?

1060


What is methods and methodology?

1035