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);
st=con.createStatement();
String tdate =thisdate+"-"+thismonth+"-"+thisyear;
System.out.println("The Gregorian Calendar Date is:"+tdate);
StringTokenizer st2 =new StringTokenizer(tdate,"-");
urd=Integer.parseInt(st2.nextToken());
urm=Integer.parseInt(st2.nextToken());
ury=Integer.parseInt(st2.nextToken());
d2=new Dates(urd,urm,ury);
To retrive Date From Database i use the Following Code
while(rs.next())
{
Date Bretrundate = rs.getDate("BReturn");
System.out.println("THE SELECTED DATE FORMATE:"+Bretrundate);
}
Now my Problem is Today's Date is in6/4/2007 formate But the Date Which I retrive from Database is in2007-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
Cheers
Jofin

