Announcement Announcement Module
Collapse
No announcement yet.
HttpInvoker and Dates timezone issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpInvoker and Dates timezone issue

    Hi,

    I have two machines setup. the machines are identical, same hardware, jvm, tomcat and os. The first machine runs a web application that gets data from another web application running on the second machine. The web apps use springs HttpInvoker mechanism.

    What I have noticed is that any dates transferred between the web apps have a different timezone. They start off in BST on the seconds machine and then end up in GMT on the first machine.

    If i type date in the shell of both machines they both report the time in BST.

    Any one got any ideas?

  • #2
    Do you refer to java.util.Date instances? Just wondering, because Date does not have timezone information. Could you provide more details?

    Regards,
    Andreas

    Comment


    • #3
      Yes i mean java.util.Date instances. Im connected to both webapps via a debugger which uses the dates toString() method to show the dates.

      Comment


      • #4
        I would not rely on Date.toString(). Important is, that Date.getTime() yields the same value for both Date instances. Is that the case?

        Comment


        • #5
          Yes the both report the same value. So i guess its down to the way im displaying them in the html interface to web app 1

          Comment


          • #6
            Originally posted by jamin View Post
            Yes the both report the same value. So i guess its down to the way im displaying them in the html interface to web app 1
            Yes, I think so. If you really need timezone information I would use Calendar instead (or some class of a more usable date library). If it's just about displaying I would use an appropriate DateFormat.

            Regards,
            Andreas

            Comment


            • #7
              From the Date class..

              /**
              * Save the state of this object to a stream (i.e., serialize it).
              *
              * @serialData The value returned by <code>getTime()</code>
              * is emitted (long). This represents the offset from
              * January 1, 1970, 00:00:00 GMT in milliseconds.
              */
              private void writeObject(ObjectOutputStream s)
              throws IOException
              {
              s.writeLong(getTimeImpl());
              }

              This explains the change in zone.

              Comment

              Working...
              X