How to check for null int/null Date
807589Jul 15 2008 — edited Jul 15 2008Heres the situation, there is an interface accepting an int value and a time/date that are not required(and are not set to anything automatically, i have no control over that part unfortunately), but I need to set up some sort of null/has value type of check to execute the setter when it does have a value, and ignore it when it doesnt. I am currently getting null pointers. here is my current set up:
//throws null pointer as set up below, I am assuming I might want to eliminate the "getDate" off of the end and that might clear it up.
if(data.getDate().getTime() != null)
{
tempData.setDate(data.getDate().getTime());
}
//Not sure on this one yet, the value doesn't get set to anything so I am assuming it automatically gets assigned something like -1.
if(data.getId() >= 0){
tempData.setId(data.getId());
}