Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to check for null int/null Date

807589Jul 15 2008 — edited Jul 15 2008
Heres 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());

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 12 2008
Added on Jul 15 2008
6 comments
249 views