Hi all,

I am wresting with a strange behaviour in my unit test below:

class test {

  public void passingTest2() {
        TimeZone.setDefault(TimeZone.getTimeZone("EST"));
        Date date = LegacyDateFormat.YYYYMMDD.asDate(20160101);// Eastern
Standard Time GMT-5
        LocalDate localDate = new LocalDate(date);
        assertEquals(new LocalDate(2016, 1, 1), localDate);
    }

    @Test
    public void failingTest2() {
        TimeZone.setDefault(TimeZone.getTimeZone("EET"));// Eastern
European Time GMT+2
        Date date = LegacyDateFormat.YYYYMMDD.asDate(20160101);
        LocalDate localDate = new LocalDate(date);

        System.out.println(date.toString());
        System.out.println(DateTimeZone.getDefault());
        System.out.println(localDate);
        assertEquals(new LocalDate(2016, 1, 1), localDate);
    }

}


The method failingTest() will fail only if the whole class is run, namely
the two tests are executed as they appear in the file, and it does not fail
if it is the only executed test. I am
wondering if it has something to do with some static initialization of the
LocalDate class and its dependencies.

Another question I have is about the TimeZone.setDefault(..) - as such
class comes from the java.util package I guess it is not impacting in any
way the LocalDate's computation, am I right ?

Thanks in advance,
Pietro
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to