Results 1 to 2 of 2

Thread: causes errors on null date objects

    This issue duplicates another issue.
  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2011
    Vote Rating

    Default causes errors on null date objects


    We try to store a Record (instance of which contains a date field using a JSON Writer.
    We found 2 problems related to the writeDate function in Writer.js:

    - If the date field's value is null (no date set), Writer.writeDate causes a 'NullPointerException', because there is no null-check.
    - To determine the date field's format, field.dateFormat is used, but it seems that this option is not present: Instead, the field object's config property has to be queried: field.config.dateFormat

    Our workaround:

    // Writer.js, function writeDate:
    writeDate: function(field, date) {
            var dateFormat = field.dateFormat || (field.config.dateFormat || 'timestamp');
            if (!date) {
                return null;
            switch (dateFormat) {
                case 'timestamp':
                    return date.getTime()/1000;
                case 'time':
                    return date.getTime();
                    return Ext.Date.format(date, dateFormat);
    We're using Sencha Touch Version

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    Believe this coveres the same thing:
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2

    Think my support is good? Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts