Hybrid View

  1. #1
    Sencha User
    Join Date
    Apr 2009
    Location
    France
    Posts
    50
    Vote Rating
    0
    G.edwin is on a distinguished road

      0  

    Default Date change on client side - TimeZone

    Date change on client side - TimeZone


    Hi,

    I faced an issue with dates, we have deployed an application on a Paris' server, and the user is based in London (so we have a gap of an hour). When the user displays date recovered in database, he has an hour of difference with the database data (From a user based in Paris we can't see a difference with database's data.)

    If i change my local TimeZone, the bug appears. Some trace show that in server side, date's data are not transformed, so i guess it's on the client side or while the RPC. How can I specify in gwt-gxt to does not modify date (whatever the TimeZone of the user) ?

    Thanks a lot !

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    GWT RPC will loose timezone information. The date will actually stay the same, but the server will show it at its timezone

  3. #3
    Sencha User
    Join Date
    Apr 2009
    Location
    France
    Posts
    50
    Vote Rating
    0
    G.edwin is on a distinguished road

      0  

    Default


    Can't I force the client side to use a specific TimeZone ?
    (with DateTimeFormat.getFormat(...) or something ?)

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You can override (overload) the GWT RPC custom date serializer with any behaviour you need.

    You could also send the date not as date but as date, month and year if you need the informations regardless of timezone

  5. #5
    Sencha User
    Join Date
    Apr 2009
    Location
    France
    Posts
    50
    Vote Rating
    0
    G.edwin is on a distinguished road

      0  

    Default


    Thanks, i dig into it, and find that could be solve my problem :

    Code:
    /**
     * Custom field serializer for {@link java.util.Date}.
     */
    public final class Date_CustomFieldSerializer {
    
          public static void deserialize(SerializationStreamReader streamReader,Date instance) {
            // No fields
          }
        
          public static Date instantiate(SerializationStreamReader streamReader) throws SerializationException {
        //    return new Date(streamReader.readLong());
            return new Date(streamReader.readInt(),streamReader.readInt(),streamReader.readInt(),streamReader.readInt(),streamReader.readInt());
          }
        
          public static void serialize(SerializationStreamWriter streamWriter,
              Date instance) throws SerializationException {
        //    streamWriter.writeLong(instance.getTime());
              System.out.println("serialize date...");
            streamWriter.writeInt(instance.getYear());
            streamWriter.writeInt(instance.getMonth());
            streamWriter.writeInt(instance.getDate());
            streamWriter.writeInt(instance.getHours());
            streamWriter.writeInt(instance.getMinutes());
          } 
    }
    But, should i have to replace the GWT Date_CustomFieldSerializer class by this one ? Or is there a way i could use my Date_CustomFieldSerializer instead of the GWT's one ?

  6. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You need to overload it. But yours higher in the classpath than the GWT one.

  7. #7
    Ext GWT Premium Member
    Join Date
    Mar 2007
    Location
    Houston, TX
    Posts
    14
    Vote Rating
    0
    tbenbrahim is on a distinguished road

      0  

    Default


    I would suggest you educate your users, rather than change anything.
    If someone modified a record at 1000 in Paris, it was 0900 in London.
    Since the user in Paris sees 1000 and the one in London see 0900, both representing the same instance in local time, I fail to see the problem.
    By the way, if a user in London saves 1000 and then sees 0900, there is a problem in the way you are saving dates, always marshall dates as Date, not String.
    If a user in London saves 1000 and then sees 1100, there is a problem in the way you are reading dates, always read Date and transfer Date, not formatted dates as String from the DB server.
    I went through the same nightmare with users in a dozen timezones, as long as you only transfer Date back and forth, the problem is gone.

Similar Threads

  1. Date columns change based on client GMT
    By Twain in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 12 Nov 2011, 1:57 PM
  2. Date with incorrect timezone
    By Tim Siney in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 18 Jan 2011, 7:56 AM
  3. client side Validation for Date
    By Alka_5m1980 in forum Community Discussion
    Replies: 0
    Last Post: 31 Mar 2009, 3:26 AM
  4. Change the client's timezone
    By keypoint in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 21 Sep 2008, 1:18 AM

Thread Participants: 7

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar