5 Replies Latest reply: Jun 22, 2011 8:55 AM by YoungWinston RSS

    Date toString() prints GMT offset

    870640
      HI -

      When I my Date instance toString() call prints the following

      Wed Jun 22 17:43:42 GMT+05:30 2011

      Whereas on my colleague's PC it prints as following

      Wed Jun 22 16:38:44 IST 2011

      Both of us are on Win XP with date timzone set to "India Standard Time" (as shown when double clicking the time in bottom right corner -system tray). Both of us are on 1.6 (he is on update 18 and I'm on 21). So not sure why the output should be different. Any pointers ?


      Thanks in advance
        • 1. Re: Date toString() prints GMT offset
          YoungWinston
          user8423284 wrote:
          Both of us are on Win XP with date timzone set to "India Standard Time" (as shown when double clicking the time in bottom right corner -system tray). Both of us are on 1.6 (he is on update 18 and I'm on 21). So not sure why the output should be different. Any pointers ?
          Are you both in India?

          Winston
          • 2. Re: Date toString() prints GMT offset
            870640
            Yes, Winston.
            • 3. Re: Date toString() prints GMT offset
              YoungWinston
              user8423284 wrote:
              Yes, Winston.
              Should have asked more specifically, are both machines "Indian" (ie, made/bought in India)?

              It's likely that one has IST supplied in the standard set of TimeZones and the other doesn't (exactly why, I'm not sure). To be honest, I doubt it'll make much difference except for display; although you may need to set DST on the GMT+0530 machine explicitly (again, not sure what IST rules are).

              Winston
              • 4. Re: Date toString() prints GMT offset
                870640
                Should have asked more specifically, are both machines "Indian" (ie, made/bought in India)?
                Not sure on that (I know mine wasn't..probably his is).

                It's likely that one has IST supplied in the standard set of TimeZones and the other doesn't
                This probably is a windows question - how/where can I see this ?

                I was initially thinking that Date.toString() would use the "ZoneInfoMappings" file I see under my "..\jdk1.6.0_21\jre\lib\zi\" directory to get the timezeone string to print (of course getting the time from the PC clock). But your reply suggests this has to do with our respective hardware somehow decides it.
                you may need to set DST on the GMT+0530 machine explicitly (again, not sure what IST rules are).
                IST does not use daylight savings.

                Thanks...
                • 5. Re: Date toString() prints GMT offset
                  YoungWinston
                  user8423284 wrote:
                  I was initially thinking that Date.toString() would use the "ZoneInfoMappings" file I see under my "..\jdk1.6.0_21\jre\lib\zi\" directory to get the timezeone string to print (of course getting the time from the PC clock). But your reply suggests this has to do with our respective hardware somehow decides it.
                  It wouldn't be hardware, since this is cropping up in Java. It may well have something to do with ZoneInfoMappings though. Sorry I can't be more explicit; maybe one of the other experts here has more info.

                  One thought would be to see if you can update your OS with the IST timezone.

                  Winston