Hey guys I have a problem. I have a start/end dates in my database (date,date2) stored as dd/mm/yyyy. I want to test if today's date is between the two dates that I've just mentionned. I tried this boolean function but it doesn't work I don't know why it returns false all the time:
private Boolean test() {
Boolean bool = false;
String ch,ch2;
Date d=new Date();
Date date2=new Date();
Date date=new Date();
try
{
rs=st.executeQuery("select *from mytab");
if(rs.next())
{
ch = rs.getString(2);
ch2 = rs.getString(3);
try
{
date = new SimpleDateFormat("dd-MM-YYYY", Locale.ENGLISH).parse(ch);
date2 = new SimpleDateFormat("dd-MM-YYYY", Locale.ENGLISH).parse(ch2);
}catch(ParseException s){
System.out.println("Check parsing");
}
if(d.before(date2) && d.after(date))
{
bool=true;
}
}
}
catch (SQLException e){System.out.println("Check the SQl");}
return bool;
}