I always get this error: "reference to Date is ambiguous, both class java.sql.Date in java.sql and class java.util.Date in java.util match"

Dermot Hennessy

It is generally bad practice, from the point of view of code maintainability, to import, e.g. java.util.*. What you should import is only those classes from the package which you are using in your class. That's point 1.

If you are using both java.util.Date and java.sql.Date, the easiest thing to do is to import one of them and to explicitly refer to the full package structure of the other every time you use it, i.e.

import java.util.Date;
... Date d = new Date(); // returns a java.util.Date
java.sql.Date d = new java.sql.Date(); speaks for itself