【问题标题】:Using DateFormatter in Flex 4在 Flex 4 中使用 DateFormatter
【发布时间】:2013-02-18 04:50:49
【问题描述】:

在 Flex 4 中使用 dateFormatter 格式化 Flex Datagrid 的列时出现错误。

函数如下:

public function dataGridFormatDateLabelFunction2(item:Object, dgColumn:Object):String
{
    var ret:String = "";
    var dt_len:Number = String(item[dgColumn.dataField]).length;

    if (dt_len > 4)
    {
        var date:Date=mx.controls.DateField.stringToDate(String(item[dgColumn.dataField]),"YYYY-MM-DD");
        ret = UIUtils.formatDate(date, "DD-MMM-YYYY");
    }
    return ret;     
}



But I am getting the following error:

TypeError:错误 #1009:无法访问空对象引用的属性或方法。 在 mx.formatters::DateBase$/http://www.adobe.com/2006/flex/mx/internal::extractTokenDate()[E:\dev\4.5.1\frameworks\projects\framework\src\mx \formatters\DateBase.as:450] 在 mx.formatters::StringFormatter/formatValue()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\formatters\StringFormatter.as:126] 在 mx.formatters::DateFormatter/format()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\formatters\DateFormatter.as:640] 在 com.flexicious.utils::UIUtils$/formatDate()

有人可以帮我解决这个错误吗?我该如何处理?

感谢您的意见。

【问题讨论】:

  • 您能否展示您的数据,让我们现在知道这些列有哪些值?最好的方法是展示整个应用程序,以便我们自己尝试。

标签: actionscript-3 apache-flex datagrid flex4.5 data-formatters


【解决方案1】:

您的日期不在“YYYY-MM-DD”中,您正在使用该格式对其进行解析。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-20
    • 2018-07-15
    • 2020-10-07
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多