Discussion Locked

compare dates from resultset

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How do I compare dates as I retrieve them from the resultset. for example I'm trying to find out whether the current date retrieved by the resultset is before or after the previous date retrieved by the resultset

2 replies

by okujava

just call:
rs.next();
Date d1 = rs.getDate(1);
rs.next();
Date d2 = rs.getDate();
if(d1.before(d2)){
System.out.println("d1 is before d2");
}

by venkatesh_ram

In Date class there are before(),after() and compareTo() methods used to compare the dates. U can use which is appropriate for u.

This discussion is closed to new replies.