Announcement

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

    How to turnoff smartgwt timezone conversion

    Hello,

    I dont want to do any timezone converions from smartgwt end. For this iam setting property DateUtil.setDefaultDisplayTimezone("+00:00") immediately on my module load... but seems to be its not working in my Listgrid aswell as DateItem too... its converting the server time to my local time according to respective timezone

    Eg: Server time is 15th Dec 2010 10:14:40 AM then
    Client time is being converting to 15th Dec 2010 03:44:40 PM

    SmartGWT Version : 2.3

    Sample Code :

    ListGridField createdDt = new ListGridField("createdDt","Created Date", 70);

    Datasource code:

    DataSourceDateField createdDt = new DataSourceDateField("createdDt");

    On immediate OnModule load, i am calling DateUtil.setDefaultDisplayTimezone("+00:00").

    FYI... i even tried out DateUtil.setDefaultDisplayTimezone("00:00") by removing +/- sign.


    Can anyone help me out...
    Also tell me from which GWT version this will work?

    Thanks,
    Bala

    #2
    Hello,

    I have created a sample test case using SmartGWT 2.3 and GWT 2.1.0 where i am facing this timezone issue.

    Sample testcase was available at below location (TimeZoneTest.zip)
    http://www.4shared.com/dir/degGaBBV/SmartClient.html

    Can anyone please help me out so that i dont want SmartGWT to convert server date/time to respective local browser timezone date/time.

    Thanks,
    Bala

    Comment


      #3
      Hello,

      Can anyone tell me how to fix this issue.

      Thanks,
      Bala

      Comment


        #4
        If you want the global DateUtil.setDefaultDisplayTimezone("00:00") setting to apply to the createdDt, then change the datasource field from DataSourceDateField to DataSourceDateTimeField and remove your custom DateUtil.setShortDateDisplayFormatter(..) and DateUtil.setDateInputFormatter(..) calls. Edit : you'll also need to set ListGrid.setDateFormatter(..).

        If you want you handle the formatting of such date's yourself then you can use DateUtil.setShortDateDisplayFormatter(..). The issue is that for what you're trying the code you have is incorrect.

        Original code :

        Code:
        DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter() {
            public String format(Date date) {
                if(date == null) {
                    return null;
                }
                // set the date format as per the WWF date preference
                DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd-MM-yyyy"+" "+"h:mm:a" );
                return return dateFormatter.format(date);
            }
        });
        You're simply formatting the date in the client browser's timezone. Use dateFormatter.format(date, TimeZone.createTimeZone(0)) instead of dateFormatter.format(date) to format the date in UTC.


        Sanjiv
        Last edited by sjivan; 16 Dec 2010, 22:15.

        Comment


          #5
          Thanks Sanjiv
          This seems to be working fine.

          Regards,
          Bala

          Comment


            #6
            I had a problem regarding the above discussion.

            When i use dateFormatter.format(date, TimeZone.createTimeZone(0)) the filter for the DateItem in the ListGrid displays a date which is one day less than the actual date in few timezones i.e if suppose you select 21/12/2010 in the DatePicker it displays 20/12/2010 in the filter. Also the date selected in the DatePicker is not highlighted when any date is selected.

            So i assume that DateUtil.setShortDateDisplayFormatter() method formats the Date only in display but the underlying date value is still different(one day less) in few timezones. I tried using DateUtil.setDateInputFormatter() as well but that did not help.

            Basically what i want is the client's browsers timezone should be overridden by the default timezone both in display as well as underlying date value which is sent to the server.

            Could you please let me know why the filter is not working as expected or is there something extra that need to be added in the above code i.e we just want to display the date which is stored at the server side without taking into consideration the client browser's timezone.


            Thanks,
            Sweta
            Last edited by swetan; 22 Dec 2010, 22:16.

            Comment


              #7
              Can anyone has fix to the above issue

              Regards,
              Bala

              Comment

              Working...
              X