Topic
1 reply Latest Post - ‏2013-06-28T07:46:13Z by 11KG_Christopher_Boyce
11KG_Christopher_Boyce
4 Posts
ACCEPTED ANSWER

Pinned topic Jviews Charts - Time Zone

‏2013-06-27T06:52:15Z |

I am creating a date format with SimpleDateFormat, and setting the correct time zone on this object.  I am passing this to IlvTimeUnit class along with a Calendar object, which also has the correct time zone set.  When the chart is rendered the time zone is defaulting to the time zone of the JVM.  Is this the expected behavior of the chart or should it use the set time zone?

                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
                sdf.setTimeZone(tz);
                
                IlvTimeUnit time_unit = new IlvMultipleTimeUnit(IlvTimeUnit.MINUTE, 30);;
                time_unit.format(sdf, Calendar.getInstance(tz));
                                
                IlvTimeStepsDefinition step_def = new IlvTimeStepsDefinition();
                step_def.setUnit(time_unit);

               chart.getXScale().setStepsDefinition(step_def);
 

 

  • 11KG_Christopher_Boyce
    4 Posts
    ACCEPTED ANSWER

    Re: Jviews Charts - Time Zone

    ‏2013-06-28T07:46:13Z  in response to 11KG_Christopher_Boyce

    Since it does not look like the charts work with timezones, I created the code below that will do the math and give me the time that I need to add to my date objects to basically get the correct output.

                TimeZone jvm_tz = TimeZone.getDefault();
                
                // Build Cal object to see what the timezone should be
                Calendar cal_jvm_tz = Calendar.getInstance(jvm_tz);
                cal_jvm_tz.set(new Integer(year), new Integer(month), new Integer(day));
                
                Calendar cal_tz = Calendar.getInstance(tz);
                cal_tz.set(new Integer(year), new Integer(month), new Integer(day));
                
                // Get the raw offsets for the timezone
                Integer jvm_timezone_offset = jvm_tz.getRawOffset();
                Integer timezone_offset     = tz.getRawOffset();
                
                // Check to see if DST is in place, then add an hour
                if (jvm_tz.inDaylightTime(cal_jvm_tz.getTime())) {
                    jvm_timezone_offset += (1000 * 60 * 60); // add an hour
                }
                
                if (tz.inDaylightTime(cal_tz.getTime())) {
                    timezone_offset += (1000 * 60 * 60); // add an hour
                }
                
                // Figure out what needs to be added to the times, since iLogs does not support Timezones
                Integer time_zone_math = timezone_offset - jvm_timezone_offset;