Announcement

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

    TimeZone Conversion In SmartGWT Client DateItem

    Hi

    I have a problem, My Server is running on America/Los_Angeles time zone , Clients are in different time zone lets say Asia/Calcutta. Server send a timestamp say "Mar/10/2010 00:00:00" problem is i don't want the dateitem to convert the date to native browser timezone that is Asia/Calcutta . I want to dateitem should select the date which is send by the server.

    I tryied with DateUtil.setDefaultDisplayTimezone() but does't work.

    Any help or suggestions


    thanks
    Anburaj.p

    #2
    Hi Anburaj,
    I am also facing the same issue. Did you find any solution for this?

    Thanks

    Comment


      #3
      I'm also searching for a solution for this.
      Is there any solution found since May ?

      Comment


        #4
        Other threads on this have ended with the conclusion that there is no bug and the setDefaultDisplayTimezone API works properly. If you think there's an issue, try creating a standalone test case.

        Comment


          #5
          Ok, I've searched about that and here is what I found :

          I use this in, the firs lines of my onModuleLoad method :
          DateUtil.setDefaultDisplayTimezone("+00:00");
          DateUtil.setAdjustForDST(false);

          But when I select a date (for example 17/11/2010), it is the value 2010-11-16T23:00:00 that is really sent to the server.
          I tried to change the DefaultDisplayTimeZone and AdjustforDST but nothing change ... anyone have an idea ?

          Comment


            #6
            What version of SmartGwt are you using? We are using smartgwt 2.2 and GWT 2.0.4 and we have similar problems. We are calling

            DateUtil.setDefaultDisplayTimezone("-07:00");

            but we get back +07:00.

            In my onModuleLoad I do two things...

            DateUtil.setDefaultDisplayTimezone("-07:00");
            Time.getDefaultDisplayTimezone()

            And it's set to +07:00.

            Comment


              #7
              We are using Smart GWT Pro 2.3, nightly build from November 16, 2010 and GWT 2.0.3...

              Comment


                #8
                Can you please support my developer Romain on this issue because we have to deploy a version for our client end of this week?

                It seems that
                DateUtil.setDefaultDisplayTimezone();
                Time.getDefaultDisplayTimezone()

                does not work properly.
                Can you do your maximum to help us?

                Benoît

                Comment


                  #9
                  This should now be resolved (Fix will be present in the next nightly build)
                  Please let us know if you continue to see the problem.

                  Also for clarification - you say you are calling Time.getDefaultDisplayTimezone() - do you mean you are calling that method in JavaScript on the JS isc.Time object?

                  Comment


                    #10
                    I just don't use any time Object, I only want to set a default Timezone on my date Item with the DateUtil API.
                    I will try it tommorow with the last nightly and let you know the result.

                    Comment


                      #11
                      Today's nightly build generates an error:
                      Code:
                      [INFO]    Scanning for additional dependencies: jar:file:/C:/Java/m2repo/com/smartgwt/smartgwt/2.3.241110/smartgwt-2.3.241110.jar!/com/smartgwt/client/util/I18nUtil.java
                      [INFO]       Computing all possible rebind results for 'com.smartgwt.client.i18n.SmartGwtMessages'
                      [INFO]          Rebinding com.smartgwt.client.i18n.SmartGwtMessages
                      [INFO]             Invoking com.google.gwt.dev.javac.StandardGeneratorContext@1362948
                      [INFO]                Processing interface com.smartgwt.client.i18n.SmartGwtMessages
                      [INFO]                   Generating method body for multiFilePicker_emptyMessage()
                      [INFO]                      [ERROR] Unterminated single quote: Cliquer sur l'icône pour ajouter...
                      [INFO] java.text.ParseException: Unterminated single quote: Cliquer sur l'icône pour ajouter...
                      [INFO] 	at com.google.gwt.i18n.rebind.MessageFormatParser.parse(MessageFormatParser.java:233)
                      [INFO] 	at com.google.gwt.i18n.rebind.MessagesMethodCreator.generateString(MessagesMethodCreator.java:452)
                      [INFO] 	at com.google.gwt.i18n.rebind.MessagesMethodCreator.createMethodFor(MessagesMethodCreator.java:367)
                      [INFO] 	at com.google.gwt.i18n.rebind.AbstractLocalizableImplCreator.delegateToCreator(AbstractLocalizableImplCreator.java:313)
                      [INFO] 	at com.google.gwt.i18n.rebind.MessagesImplCreator.emitMethodBody(MessagesImplCreator.java:84)
                      [INFO] 	at com.google.gwt.user.rebind.AbstractGeneratorClassCreator.genMethod(AbstractGeneratorClassCreator.java:265)
                      [INFO] 	at com.google.gwt.user.rebind.AbstractGeneratorClassCreator.emitMethods(AbstractGeneratorClassCreator.java:233)
                      [INFO] 	at com.google.gwt.user.rebind.AbstractGeneratorClassCreator.emitClass(AbstractGeneratorClassCreator.java:116)
                      [INFO] 	at com.google.gwt.i18n.rebind.AbstractLocalizableImplCreator.generateConstantOrMessageClass(AbstractLocalizableImplCreator.java:137)
                      [INFO] 	at com.google.gwt.i18n.rebind.LocalizableGenerator.generate(LocalizableGenerator.java:121)
                      [INFO] 	at com.google.gwt.i18n.rebind.LocalizableGenerator.generate(LocalizableGenerator.java:98)
                      [INFO] 	at com.google.gwt.dev.javac.StandardGeneratorContext.runGenerator(StandardGeneratorContext.java:418)
                      [INFO] 	at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:38)
                      [INFO] 	at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.tryRebind(StandardRebindOracle.java:108)
                      [INFO] 	at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:54)
                      [INFO] 	at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:154)
                      [INFO] 	at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:143)
                      [INFO] 	at com.google.gwt.dev.Precompile$DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(Precompile.java:317)
                      [INFO] 	at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.doFindAdditionalTypesUsingRebinds(WebModeCompilerFrontEnd.java:95)
                      [INFO] 	at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.process(AbstractCompiler.java:200)
                      [INFO] 	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
                      [INFO] 	at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:123)
                      [INFO] 	at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:234)
                      [INFO] 	at com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.access$200(AbstractCompiler.java:109)
                      [INFO] 	at com.google.gwt.dev.jdt.AbstractCompiler.compile(AbstractCompiler.java:522)
                      [INFO] 	at com.google.gwt.dev.jdt.BasicWebModeCompiler.getCompilationUnitDeclarations(BasicWebModeCompiler.java:112)
                      [INFO] 	at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.getCompilationUnitDeclarations(WebModeCompilerFrontEnd.java:47)
                      [INFO] 	at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:422)
                      [INFO] 	at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:32)
                      [INFO] 	at com.google.gwt.dev.Precompile.precompile(Precompile.java:522)
                      [INFO] 	at com.google.gwt.dev.Precompile.precompile(Precompile.java:414)
                      [INFO] 	at com.google.gwt.dev.Compiler.run(Compiler.java:201)
                      [INFO] 	at com.google.gwt.dev.Compiler$1.run(Compiler.java:152)
                      [INFO] 	at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:87)
                      [INFO] 	at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:81)
                      [INFO] 	at com.google.gwt.dev.Compiler.main(Compiler.java:159)
                      [INFO]    [ERROR] Errors in 'jar:file:/C:/Java/m2repo/com/smartgwt/smartgwt/2.3.241110/smartgwt-2.3.241110.jar!/com/smartgwt/client/util/I18nUtil.java'
                      [INFO]       [ERROR] Line 31:  Failed to resolve 'com.smartgwt.client.i18n.SmartGwtMessages' via deferred binding
                      [INFO]    Scanning for additional dependencies: jar:file:/C:/Java/m2repo/com/google/gwt/gwt-user/2.0.3/gwt-user-2.0.3.jar!/com/google/gwt/emul/java/lang/StringBuffer.java
                      [INFO]       [WARN] For the following type(s), generated source was never committed (did you forget to call commit()?)
                      [INFO]          [WARN] com.smartgwt.client.i18n.SmartGwtMessages_fr
                      [INFO]    [ERROR] Cannot proceed due to previous errors

                      line 364 of SmartGWTMessage_fr.properties and SmartGWTMessage_fr_FR.properties are not correct and should be : multiFilePicker_emptyMessage=Cliquer sur l\'\'icône pour ajouter...
                      Last edited by romain.vdk; 23 Nov 2010, 23:50.

                      Comment


                        #12
                        The timezone bug is still present with the last nightly build.

                        Comment


                          #13
                          Yes, Sorry about that. I was using a native method to call Time.getDefaultDisplayTimezone() just to clarify if it was set correctly.

                          Also, i do agree with romain that this issue it still present. And, in fact calling Time.getDefaultDisplayTimezone() gives me the correct value now, but the Date object that a date picker gives me is still incorrect. It seems like it is still using the browser timezone. In my case, I'm in America/Chicago timezone. If i set my timezone to -7:00 (America/Denver ) I would expect
                          Thu Nov 25 07:00:00 UTC 2010
                          but i get
                          Thu Nov 25 06:00:00 UTC 2010.

                          Am i correct in assuming this should be the correct behavior?

                          Comment


                            #14
                            Use nightly builds from smartclient.com/builds, not SVN.

                            Comment


                              #15
                              Here is the way we fixed this :
                              Code:
                                  /**
                                   * As SmartGwt converts date to GMT date, we want to send the dates as shown by the user so we have
                                   * to re-inject their time zones to the date
                                   * @param gmtDate the date we want to modify
                                   * @return the user time zoned date
                                   */
                                  public static Date getTimeZonedDate(Date gmtDate) {
                                      final String timezone = DateTimeFormat.getFormat("Z").format(new Date());
                                      int hours = 0, minutes = 0;
                                      boolean plus = true;
                                      Date modDate = null;
                                      if ( timezone.matches("^[+\\-]{1}[0-9]{4}$") )  {
                                          if ( '-' == timezone.charAt(0) ) plus = false;
                                          try {
                                              hours = Integer.parseInt(timezone.substring(1,3));
                                              minutes = Integer.parseInt(timezone.substring(3));
                                          }  catch ( NumberFormatException ex ) {}
                                          long hourLong = hours * 60 * 60 * 1000 ; // miliseconds conversion
                                          long minutesLong = minutes * 60 * 1000 ; // miliseconds conversion
                                          long modDateLong = gmtDate.getTime();
                                          if ( plus ) {
                                              modDateLong = modDateLong + hourLong + minutesLong ;
                                          } else {
                                              modDateLong = modDateLong - hourLong - minutesLong ; 
                                          }
                                          modDate = new Date(modDateLong);
                                      } else {
                                          modDate = gmtDate;
                                      }
                                      return modDate;
                                  }
                              We add the timezone to the current date before converting it so when smartgwt convert it to GMT time, we have the correct entered date sent to the server.

                              Comment

                              Working...
                              X