If I remember correctly, every object in java can be null. Primitive types ( int, double, float, char , etc.) cannot be null. To use null with them you must use their object instance ( Integer, Double, Float... )
As for dates, java.util.Date is an object, so it can be null. The same goes for Calendar and GregorianCalendar.
the equivalent code would look something like this:
public Date date(Date dt) throws NullPointerException { if (dt == null) throw new NullPointerException(); ... }
In C # can you use? to allow null val in primitive types (for example, to force the null reference of an object to be checked). I donβt understand why this thing bothers you. If you need, for example, a null integer parameter in java, you just need to use java.lang.Integer , not a primitive int type.
source share