while (r.next()) {
String rn = r.getString(3);
String sqldate = r.getString(2); // database reservation date
}
Getting date from database
DateFormat RD = new SimpleDateFormat("yyyy-MM-dd");
java.sql.Date converteddate = new java.sql.Date(RD.parse(sqldate).getTime());
Calendar cal = Calendar.getInstance();
Calendar cal1 = Calendar.getInstance();
cal.setTime(converteddate);
cal.add(Calendar.DATE, 7);
if(cal<=cal1){ }// i need to this opration i dont know how
I need to check cal is <= Cal1. Any ideas?
How about using the simple method:
This reads: “If a date is before another date, you should do the following..”.
I think it makes it easier to read if you write “before” than “compareTo”, even though the operation is the same. Also read the documentation for Java Calendar.
EDIT:
I’ve updated the answer a bit to include what’s been commented below so the answer is more complete. Thanks to assylias for pointing it out, but if you want to compare if a date is before or equal to another date, you should use:
This reads: “If a date is not after another date, you should do the following..”. Also note that “not after” is the same as “before or equal to”.