The method Dates.getTimezoneOffset is not working properly for some dates. This leads to incorrect display of such dates in the components Datebox and Timebox.

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None

      The method Dates.getTimezoneOffset is not working properly for some dates.
      This leads to incorrect display of such dates in the components Datebox and Timebox.
      For example for birth date (dd.mm.yyyy) 11.10.1978 for timezone "Europe/Moscow":

      GregorianCalendar testGregorianCalendar = new GregorianCalendar();
      testGregorianCalendar.set(Calendar.DAY_OF_MONTH, 11);
      testGregorianCalendar.set(Calendar.MONTH, 9);
      testGregorianCalendar.set(Calendar.YEAR, 1978);
      testGregorianCalendar.set(Calendar.HOUR_OF_DAY, 0);
      testGregorianCalendar.set(Calendar.MINUTE, 12);

      Date date = new Date(testGregorianCalendar.getTimeInMillis());

      System.out.println("Dates.getTimezoneOffset|" + Dates.getTimezoneOffset(TimeZone.getTimeZone("Europe/Moscow"), date));
      System.out.println("TimeZone.getTimeZone(\"Europe/Moscow\").getOffset|" + TimeZone.getTimeZone("Europe/Moscow").getOffset(date.getTime()));

      Output:

      Dates.getTimezoneOffset|14400000 // 4 hours - INCORRECT - in 1978 in "Europe/Moscow" offset WAS 3 hours (4 hours is current offset not in 1978)
      TimeZone.getTimeZone("Europe/Moscow").getOffset|10800000 // 3 hours - CORRECT - in 1978 in "Europe/Moscow" offset WAS 3 hours

      This leads to incorrect display of such dates in the components Datebox and Timebox if TimeZones.getCurrent() is not equal timezone of the component.
      11.10.1978 00:12 displayed as 10.10.1978 (date - from code above; TimeZones.getCurrent() is "Europe/Moscow"):

      birthdateDatebox1.setTimeZone(TimeZone.getTimeZone("GMT"));
      birthdateDatebox1.setValue(date);

            Assignee:
            Unassigned
            Reporter:
            gamecat
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: