compare Date yyyy-mm-dd only
8
If you only want to compare yyyy-mm-dd you can use the java.sql.Date class, the valueOf method does the trick. It's perfectly safe as the sql Date class is a subclass of the Date class.
Check out the docs here for more detail.
enjoy
Check out the docs here for more detail.
enjoy
import java.sql.Date;
class DateTest {
public static void main(String[] args) {
Date today = Date.valueOf("2006-08-08"); // use date of today here
Date alsoToday = new Date(System.currentTimeMillis()); // has time information and will probably not be equal to "today"
System.out.println(today.equals(alsoToday)); // false
System.out.println(today.equals(Date.valueOf(alsoToday.toString()))); // true
}
}






There are currently no comments for this snippet.