I suspect you want:
public void foo(Date date) { if (date != null) {
Please note that unlike DateTime in .NET, java.util.Date is a class (and therefore a reference type) ... Java does not have βcustomβ value types.
Also note that this is not exactly the same as the variable being βsetβ. For instance:
Date date = new Date(); date = null;
Do you consider this variable βsetβ or not? It must have a null reference as its value. I suspect you want to know if the variable has a value related to the object, but this is not exactly the same.
source share