开发者

Proper way to check for null dates in Flex/Actionscript?

When working with Date() objects in Flex/Actionscript, I'm using to following function to check for null dates. Is this the proper way to check for a null date or is there a better alternative out there?

public function IsDateNull(date:Date):Boolean
{
  if (date 开发者_如何学编程&& date.fullYear != 0)
  {
    return true;
  }

  return false;
}


Since Date is a class that extends Object and isn't a primitive type it doesn't have a default value and therefore should only be null if it hasn't yet been instantiated. Is the Date being populated from some sort of database mapping or something along those lines? otherwise not just

if(!date)

or

if(date==null)

no need to have a function to do this. For the DateField.selectedDate the value should be null if no date has been selected yet. This wasn't originally posted as an answer because I don't entirely understand the issue being encountered it sounds as though there's a variety of cases though. Depending on the service layer and underlying JDBC (or other connector) to the DB and the type of DB and datatype the values can vary. In general a Date will be null until memory is acquired for it through a call to the constructor though.

Thanks, Shaun

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜