Sorting out the dates in chronological order
<p>Friends I am having a String that contains date-record</p>

<pre><code>String date=10-Oct-2012 @12-Oct-2012 @$12-Oct-2012 @12-Oct-2012 @$12-Sept-2012 13:50@12-Oct-2012 13:50@$12-Feb-2012 13:50@12-Oct-2012 13:50@$

List&lt;Date&gt; myList=new ArrayList&lt;Date&gt;() ;
</code></pre>

<p>I need to compare the dates <code>10-Oct-2012,12-OCt-2012,12-Sept-2012,12-Feb-2012</code> ie every odd date such that I can arrange them in a chronological order.I am confused on this implementation, please provide me with guidance/hint to solve the problem.</p>

<p>In this case the solution after chronological order would be <code>12-Feb-2012 @12-Oct-2012 @12-Sept-2012  @12-Oct-2012  @$10-Oct-2012 @12-Oct-2012 @$12-Oct-2012 @12-Oct-2012</code></p>

<p>Friends,to solve the problem I have created a Hashmap where I am planning to save the first date as key and the entire String as value. </p>

<pre><code>String[] tokens=date.split("\\$");
    demo[0]=demo[0].replaceAll("-", ".");
if(tokens.length&gt;0)
        {
            for(int iTmp=tokens.length-1;iTmp&gt;=0;iTmp--)
            {
                String []demo = tokens[iTmp].split("\\@");
                    demo[0] = demo[0].replace("Jan", "1")
                    .replace("Feb", "2").replace("March","3").replace("April","4").replace("May","5").replace("Jun","6").replace("July","7").replace("Aug","8")
                    .replace("Sept","9").replace("Oct","10").replace("Nov","11").replace("Dec","12");
                    demo[0]=demo[0]+" 00:05:00";
                    Date date1 = null;
                    SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yy");


                    try {
                        date1 = (Date)formatter.parse(demo[0]);

                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    myList.add(date1);
                    System.out.println("ADDED DATE IS"+date1);
                    //System.out.println("KEY VALUE PAIRS  "+key+"  "+tokens[iTmp]);
                }
            }
            System.out.println("READING LISTs");
            for(int iTmp=0;iTmp&lt;myList.size();iTmp++)
            {

                System.out.println(myList.get(iTmp));
            }
            Collections.sort(myList);
            System.out.println("After Sorting");
            for(int iTmp=0;iTmp&lt;myList.size();iTmp++)
            {

                System.out.println(myList.get(iTmp));
                System.out.println();
            } 
</code></pre>
