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

Can we use this () and super () in a method?

940


What do you mean by inner class in java?

1043


How to make a class or a bean serializable?

932


What are the main features of java?

931


What is floor math?

937


What is meant by method?

1038


What is a native method in java programming?

1023


How do you declare an array that will hold more than 64KB of data?

1221


How do constructors use this() and super()?

1073


What a static class can contains?

1115


What is the unit of plancks constant?

1004


How do you replace all in word?

1009


What is polymorphism and what are the types of it?

953


Is a case study a method or methodology?

859


What is instanceof keyword?

1185