1. #1
    Ext User
    Join Date
    Aug 2007
    Posts
    14
    Vote Rating
    0
    quartex is on a distinguished road

      0  

    Default java Json Date

    java Json Date


    Hi,
    I'm using a java procedure to send data to Ext client and I have JsonReader in mygrid to display a date field with this code

    PHP Code:
    reader: new Ext.data.JsonReader({
              
    root'topics',
              
    totalProperty'totalCount',
              
    id'id',
              
    fields: [
                  
    'subject''queue''resolution','status',
                  {
    name'created'mapping'created'type'date'dateFormat'timestamp'}
                  
              ]
          }) 
    but I have a problem because the date displaied are all wrongs (like Sep 11, 40014, 7:40 am)
    I use Json lib to serialize a java Date object and I test the conversion for date (yyyy-mm-dd hh:mms): 2008-01-17 13:56:30.0 becomes serialized in 1200574590000.
    In another example for Json in Ext forum I see a format like this "lastpost":"1200320864"
    Is there another configuration for dateFormat: 'timestamp' to parse correctly the date field ?
    Thanks a lot for all help

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    The dateFormat config option accepts something that you would give to Date.dateParse.

    A list of available options is here: http://extjs.com/deploy/dev/docs/?class=Date

  3. #3
    Ext User
    Join Date
    Aug 2007
    Posts
    14
    Vote Rating
    0
    quartex is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    The dateFormat config option accepts something that you would give to Date.dateParse.

    A list of available options is here: http://extjs.com/deploy/dev/docs/?class=Date
    Hi,
    thanks a lot for help ... but I do not found dateFormat: 'timestamp' in this options list.
    I search in help for timestamp but I do not found anything ....

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Convert the date to a real date, ie create the JSON String like this:

    Code:
    out.write("new Date(" + myCalendar.get(Calendar.YEAR) + "," +
        myCalendar.get(Calendar.MONTH) + "," +
        myCalendar.get(Calendar.DAY_OF_MONTH) + ")");
    You still need a dateFormat, but that's just for the output of the data, it arrives in Javascript as a fully instantiated Date object with no need for any parsing.

  5. #5
    Ext User
    Join Date
    Aug 2007
    Posts
    14
    Vote Rating
    0
    quartex is on a distinguished road

      0  

    Default


    Quote Originally Posted by Animal View Post
    Convert the date to a real date, ie create the JSON String like this:

    Code:
    out.write("new Date(" + myCalendar.get(Calendar.YEAR) + "," +
        myCalendar.get(Calendar.MONTH) + "," +
        myCalendar.get(Calendar.DAY_OF_MONTH) + ")");
    You still need a dateFormat, but that's just for the output of the data, it arrives in Javascript as a fully instantiated Date object with no need for any parsing.
    After test I understand "timestamp" format is equals to "U" format (I do not find "timespamp" everywhere) and I modified Json lib to have date in seconds format instead millisecond like standard for javaa.
    Thanks a lot Animal for help

Thread Participants: 2