You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bruno P. Kinoshita (JIRA)" <ji...@apache.org> on 2014/01/07 14:31:50 UTC

[jira] [Comment Edited] (LANG-943) Test DurationFormatUtilsTest.testEdgeDuration fails in JDK 1.6, 1.7 and 1.8, BRST time zone

    [ https://issues.apache.org/jira/browse/LANG-943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13864230#comment-13864230 ] 

Bruno P. Kinoshita edited comment on LANG-943 at 1/7/14 1:29 PM:
-----------------------------------------------------------------

Not sure if it was intentional, but the test is using the first day of daylight saving time in Brazil in 2005 [1].

When I runt he code below, I get 1, instead of 0.

{code}
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
cal.set(2005, 9, 16, 0, 0, 0);
System.out.println(cal.get(Calendar.HOUR_OF_DAY));
{code}

So in the testEdgeDurations test, with the America/Sao_Paulo time zone, it is comparing the difference in days between 16/10/2005 01:00:00 and 01/01/2006 00:00:00. While the expected result is 77, because of this 01 hour added, the result is 76 (you can try that in [2]).

I fixed the issue locally, by adding the following line right after the testEdgeDurations method declaration:

{code}
// Since the test seems to expect the result to be timezone-agnostic
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
{code}

Does this seem like a valid fix for this issue? Without this, DateFormatUtils gets America/Sao_Paulo from TimeZone.getDefault(), what causes the test to fail.

Cheers

[1] http://pt.wikipedia.org/wiki/Anexo:Lista_de_per%C3%ADodos_em_que_vigorou_o_hor%C3%A1rio_de_ver%C3%A3o_no_Brasil
[2] http://www.onlineconversion.com/days_between_advanced.htm


was (Author: kinow):
Not sure if it was intentional, but the test is using the first day of daylight saving time in Brazil in 2005 [1].

When I runt he code below, I get 1, instead of 0.

{code}
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
cal.set(2005, 9, 16, 0, 0, 0);
System.out.println(cal.get(Calendar.HOUR_OF_DAY));
{/code}

So in the testEdgeDurations test, with the America/Sao_Paulo time zone, it is comparing the difference in days between 16/10/2005 01:00:00 and 01/01/2006 00:00:00. While the expected result is 77, because of this 01 hour added, the result is 76 (you can try that in [2]).

I fixed the issue locally, by adding the following line right after the testEdgeDurations method declaration:

{code}
// Since the test seems to expect the result to be timezone-agnostic
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
{/code}

Does this seem like a valid fix for this issue? Without this, DateFormatUtils gets America/Sao_Paulo from TimeZone.getDefault(), what causes the test to fail.

Cheers

[1] http://pt.wikipedia.org/wiki/Anexo:Lista_de_per%C3%ADodos_em_que_vigorou_o_hor%C3%A1rio_de_ver%C3%A3o_no_Brasil
[2] http://www.onlineconversion.com/days_between_advanced.htm

> Test DurationFormatUtilsTest.testEdgeDuration fails in JDK 1.6, 1.7 and 1.8, BRST time zone
> -------------------------------------------------------------------------------------------
>
>                 Key: LANG-943
>                 URL: https://issues.apache.org/jira/browse/LANG-943
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 3.1, 3.2, 3.2.1
>         Environment: Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 12:22:22-0300)
> Maven home: /opt/java/apache-maven-3.1.1
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux", version: "3.11.0-14-generic", arch: "amd64", family: "unix"
> JDK 1.6.0_27, JDK 1.7.0_25, JDK 1.7.0_25
>            Reporter: Bruno P. Kinoshita
>              Labels: test-fail, timezone
>             Fix For: Patch Needed
>
>
> While helping testing LANG-942 with JDK1.8 I always got three tests failing, while others had 2. After @britter fixed the issues related to JDK1.8, I continue getting errors with JDK1.8.
> I decided to vote for [lang] 3.2.1 and test the tag with JDK 1.8 and a few others. However, I'm getting errors with any JDK, 1.6, 1.7 and 1.8 (build 121). Always the same error:
> Failed tests: 
>   DurationFormatUtilsTest.testEdgeDurations:467->assertEqualDuration:562->assertEqualDuration:575 expected:<7[7]> but was:<7[6]>
> I get the same error with JDK 1.6 and the tag 3.1
> Since the test is somewhat related to Time Zones (there are some Calendar's, TimeZone.getDefault(), etc), here's my locale and time zone:
> kinow@chuva:~/java/apache/commons-lang-31$ locale
> LANG=en_US.UTF-8
> LANGUAGE=en_US
> LC_CTYPE="en_US.UTF-8"
> LC_NUMERIC="en_US.UTF-8"
> LC_TIME="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
> LC_MONETARY="en_US.UTF-8"
> LC_MESSAGES="en_US.UTF-8"
> LC_PAPER="en_US.UTF-8"
> LC_NAME="en_US.UTF-8"
> LC_ADDRESS="en_US.UTF-8"
> LC_TELEPHONE="en_US.UTF-8"
> LC_MEASUREMENT="en_US.UTF-8"
> LC_IDENTIFICATION="en_US.UTF-8"
> LC_ALL=
> kinow@chuva:~/java/apache/commons-lang-31$ date
> Sun Jan  5 21:23:05 BRST 2014



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)