1 Reply Latest reply: Apr 6, 2007 6:25 AM by 807606 RSS

    Comparing Two Dates

      Hi Friends

      My actual problem is i want to compare two Dates That is i have a Datefield In the DataBase table. i retrive those fields and Compare them With Today's Date Whether they are Less Than Today's Date.

      To get today's Date I use the Following Code:
      GregorianCalendar gcal=new GregorianCalendar();
                     int thisdate= gcal.get(Calendar.DATE);
                     int thismonth=(int)gcal.get(Calendar.MONTH)+1;
                     int thisyear= gcal.get(Calendar.YEAR);
                     String tdate =thisdate+"-"+thismonth+"-"+thisyear;
                      System.out.println("The Gregorian Calendar Date is:"+tdate);
                      StringTokenizer st2 = new StringTokenizer(tdate,"-");
                      d2= new Dates(urd,urm,ury);
      To retrive Date From Database i use the Following Code
                          Date Bretrundate = rs.getDate("BReturn");     
                          System.out.println("THE SELECTED DATE FORMATE:"+Bretrundate);     
      Now my Problem is Today's Date is in 6/4/2007 formate But the Date Which I retrive from Database is in 2007-04-13

      I don't know to compare them and find out Whether the Date which are stored in the Database is Less than Today's Date

      Please give me some sample to me to Understand.

      Thank you very much for your service