14 Replies Latest reply: Jul 21, 2011 1:54 AM by 798692 RSS

    timezone problem in JRE 1.6.0_22

    641325
      Hello Friends,

      I am pretty new to Java and especially problem like this :)

      I am using JRE 1.6.0_22 in my Java application. My application binary will be done using maven build.

      My application binary will contain JRE and it will be installed before my application as its pre-requirement to run my application.

      My application used to write lotz of log information for troubleshooting. Now my problem is my application writing the logs with wrong time stamp. which means when i am running the application the date time of the computer is not taken into account as the timezone. It always saying the time as which is very irrelevant to my time. i suspect there is a problem in the timezone of my JVM.

      And some more information is, maven build was implemented in my project some months back. before that everything is basked on batch file system. That time i never faced this issue. But the JRE version are different. I meant JRE version is lower than 1.6.0_22.

      Now i am not able to guess whether the problem is because of my maven configuration? if so, i will get this problem with all the computer wherever i am installing my application. This is not happening. its used to some 3 out of 10 computers only.

      If the problem is because of my JRE timezone? or any such problem identified in 1.6.0_22?

      Please friends help me to solve this issue. I don't know from where to start my investigation.

      Thanks in advance!
      Arun S
        • 1. Re: timezone problem in JRE 1.6.0_22
          sabre150
          The JRE takes it default time zone from your OS. Are you sure the OS clock is set to the correct time zone?
          • 2. Re: timezone problem in JRE 1.6.0_22
            641325
            Hello,

            Thanks for the reply. yes i am very sure my OS timezone is set properly and the time showing in my computer is very accurate to my timezone.. still my application log time is irrelevant.

            Thank You!
            • 3. Re: timezone problem in JRE 1.6.0_22
              baftos
              Can you post the relevant code that logs, a bad line from the log and the expected equivalent line?
              • 4. Re: timezone problem in JRE 1.6.0_22
                641325
                Hello,

                Thanks for the reply.

                This is the way i am constructing my time
                 time = DateFormat.getTimeInstance(DateFormat.MEDIUM, NmcLocale.get()).format(new Date()); 
                When i debug this code my locale is fine. And also i tried to put some traces to find the locale in the installed application still locale is correct. I feel, locale is to decide the format of the time..correct me if i am wrong.

                I guess the data instance giving me the wrong information.

                Please help me to understand the problem.

                Thank You!!
                • 5. Re: timezone problem in JRE 1.6.0_22
                  796440
                  user638322 wrote:
                   time = DateFormat.getTimeInstance(DateFormat.MEDIUM, NmcLocale.get()).format(new Date()); 
                  When i debug this code my locale is fine. And also i tried to put some traces to find the locale in the installed application still locale is correct. I feel, locale is to decide the format of the time..correct me if i am wrong.

                  I guess the data instance giving me the wrong information.
                  I would start by running something like the following on all the computers--the ones that work and the ones that don't. It sounds like you've done some of this, but if we don't know exactly what you did and exactly what results you got, it's pretty much impossible to determine what the source of the problem is.
                  System.out.println(Locale.getDefault());
                  System.out.println(NmcLocale.get());
                  System.out.println(TimeZone.getDefault());
                  System.out.println(DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.getDefault()).getTimeZone());
                  System.out.println(DateFormat.getTimeInstance(DateFormat.MEDIUM, NmcLocale.get()).getTimeZone());
                  System.out.println(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL,  Locale.getDefault()).format(new Date()));
                  System.out.println(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, NmcLocale.get()).format(new Date()));
                  Print out that stuff, and anything else you can think of that might be relevant, and then look for patterns that show one value on the machines that work and a different value on the machines that don't. Once you find the pattern, you have a likely cause, and can start investigating down that path.
                  • 6. Re: timezone problem in JRE 1.6.0_22
                    641325
                    Hello,

                    Thank you for your reply.

                    Let me add some more points on this.

                    My application will support many languages like English, French, German, etc.. Here NmcLocale is my wrapper class which will store the Locale when the user login with their desired language.

                    Here
                    NmcLocale.get()
                    will give you the corresponding Locale.

                    But i want to clear doubt here, is Locale used only to decide the time format rite? or the TimeZone also?

                    More over when i am putting some logs on the installed application to find the Locale; my Locale is correct with respective to my log in language.

                    So still i am confused from where the TimeZone is taken by my JVM?

                    Please guide me

                    Thank you!
                    • 7. Re: timezone problem in JRE 1.6.0_22
                      798692
                      Arun wrote:
                      But i want to clear doubt here, is Locale used only to decide the time format rite? or the TimeZone also?
                      Not TimeZone. Locale decides only the time format.
                      So still i am confused from where the TimeZone is taken by my JVM?
                      TimeZone.getDefault() gets your default time zone. In linux it is configured in the /etc/localtime file
                      • 8. Re: timezone problem in JRE 1.6.0_22
                        796440
                        Arun wrote:
                        Please guide me
                        I already guided you. I suggested that you print out as much potentially relevant information as possible and look for a pattern, and post the results here if you still need help. Since you haven't done that, there's nothing more I can add.

                        No, the Locale doesn't influence the TZ, just the format. However, I don't believe you said what is wrong with the time on the 3 bad hosts. So I consider the possibility that their Locale is such that the time is being displayed in a format that's different from the good hosts, and that perhaps you're not realizing this difference, and therefore perhaps you are misinterpreting what you're seeing.

                        But at the moment, you're jumping ahead and trying to ignore Locale because it doesn't affect TZ. My position is that we're not there yet. We're in the very beginning, at the information-gathering stage. You can go on about how you've confirmed this or that is correct on the bad machines, but we weren't there, we didn't see your test, and we didn't see your result. I'm trying to put everybody on some common ground here, and trying not to make any assumptions about what might or might not be the source of the problem.
                        • 9. Re: timezone problem in JRE 1.6.0_22
                          641325
                          Hello jverd,

                          Thanks for your kind reply.

                          As i mention its not happening from my development PC.

                          Its happening in the customer site. And i cannot replace the new jar file with the changes to get the information (or logs) you have asked. They will not accept the same.

                          Rather i have checked the timezone in their problematic PC; and everything set to their preferred timezone but the log details alone not with respective to the timezone.

                          Still i have tested and got log information asked by you in my PC but as i said those problem is not happening with my PC. i dont think giving those logs will help us to find out the issue.

                          Still i am not able to understand how the date and time is wrong when the timezone is properly set.

                          I am in need of your help friends.

                          Thank you!
                          • 10. Re: timezone problem in JRE 1.6.0_22
                            641325
                            Hello jverd,

                            Some how i got the information you have ased for..

                            Following are the log i have got from one of the problematic client...

                            If you see the timezone is set to "America/Caracas" but the time displaying is Venezuelan Standard Time (VET)

                            But if u see the time in the system tray its showing proper time.

                            Do you have any clue on this.
                             Locale.getDefault() : en_US
                            
                            NmcLocale.get() : en_US
                            
                            TimeZone.getDefault() : sun.util.calendar.ZoneInfo[id="America/Caracas",offset=-16200000,dstSavings=0,useDaylight=false,transitions=5,lastRule=null]
                            
                            DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.getDefault()).getTimeZone() : sun.util.calendar.ZoneInfo[id="America/Caracas",offset=-16200000,dstSavings=0,useDaylight=false,transitions=5,lastRule=null]
                            
                            DateFormat.getTimeInstance(DateFormat.MEDIUM, NmcLocale.get()).getTimeZone() : sun.util.calendar.ZoneInfo[id="America/Caracas",offset=-16200000,dstSavings=0,useDaylight=false,transitions=5,lastRule=null]
                            
                            DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL,  Locale.getDefault()).format(new Date()) : Tuesday, July 19, 2011 4:00:11 AM VET
                            
                            DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, NmcLocale.get()).format(new Date()) : Tuesday, July 19, 2011 4:00:11 AM VET
                            Thank you!

                            Edited by: Arun on Jul 19, 2011 2:24 AM
                            • 11. Re: timezone problem in JRE 1.6.0_22
                              darke
                              Arun wrote:
                              If you see the timezone is set to "America/Caracas" but the time displaying is Venezuelan Standard Time (VET)
                              And that's unexpected because ?
                              • 12. Re: timezone problem in JRE 1.6.0_22
                                641325
                                Hello Friends,

                                Any clue on this issue.

                                Thank You!
                                • 13. Re: timezone problem in JRE 1.6.0_22
                                  darke
                                  Arun wrote:
                                  Hello Friends,

                                  Any clue on this issue.

                                  Thank You!
                                  I'll give you a big one - Caracas (Spanish pronunciation: [kaˈɾakas]), officially Santiago de León de Caracas, is the capital and largest city of Venezuela;
                                  • 14. Re: timezone problem in JRE 1.6.0_22
                                    798692
                                    Arun wrote:
                                    If you see the timezone is set to "America/Caracas" but the time displaying is Venezuelan Standard Time (VET)
                                    It is correct. VET is the abbreviation of America/Caracas timezone. What is your problem in this?