Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    using FieldType.DATETIME with DataSource skews actual time in ListGrid

    Hello, Im having an issue with DataSource and ListGrid.
    I get a list of data transfer objects from my database and return them
    to the client side.
    I then populate a DataSource using the data from the DTOs. Ive created
    my own class that extends ListGridRecord and I fill the datasource for the listgrid with an array of my extended listgridrecord objects that get their data from the DTOs.

    Im not using smartclient.
    I set the datasource using setTestData( ). Ive been using this for a while and only now that Im working with date/times do i run into the error.

    The error is when I attach the datasource to the listgrid all of the times show up in the listgrid as 1 hour later than the actual times.

    My datasource is using FieldType.DATETIME for its values. If I use FieldType.DATE instead of DATETIME then it doesnt show the time, but the dates are correct. By this I mean that, in the listgrid, if i have a time on march 24th at 1130pm, using DATETIME the listgrid shows march 25th at 1230am, but If I use FieldType.DATE it shows up as March 24th, the correct date, sans time. I need both date and time though, and I cant see what would be causing this.

    My extended ListGridRecord class that i use to transfer the data from the DTOs (and I eventually use for setTestData() for datasource) use java.util.Date for the date/time values from the DTO's, and the DTOs
    use Timestamp. I didnt think it was anything wrong here though, because Im transferring the data to the listgridrecord objects and the data is not skewed in that transfer,
    and when i get the data back from the listgrid datasource (as DataClass objects), the date/times are right there too.

    Ive tried a test and performed a getTestData( ) procedure, and
    iterated thru the array returned. The values shows up as the correct time,
    but in the listgrid its actually displayed as 1 hour later.

    so the values are correct, but its only being displayed incorrectly.

    Id really really hate to have to go in and manually subtract an hour from the actualy and valid record objects and then readd them to the datasource and rebind them to the listgrid just so I can get a proper value displayed, and If I do it this way and need to use the data from the listgrid, i will have to go back and just add an hour to the value to make it correct again. Real Jenky.

    Any ideas on why this might be occuring?
    Please help me.

    thebravedave
    Last edited by thebravedave; 3 Apr 2010, 19:59.

    #2
    Hi,

    When communicating with server the server returns the dates in UTC (see http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/docs/DateFormatAndStorage.html). Your browser is probably in +1h time zone and this means the actual dates you are getting will be "off" by this one hour.

    Good luck getting this to work though. You could try calling http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/util/DateUtil.html#setDefaultDisplayTimezone(java.lang.String) to set the time zone to your preferred one and see if it fixes your problem. If I've understood correctly you would like to get the same time displayed as your server is returning so call this method with "00:00". I personally have been trying to get the dates, datetimes, time zones and date formats to work consistenly with no luck so far.

    br,
    Marko

    Comment

    Working...
    X