JDK-8254865 : Formatter/BasicDateTime test behaviour needs to be reverted and issue fixed
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version:
    7u291,8u281,11.0.10-oracle,15.0.2,16 7u291,8u281,11.0.10-oracle,15.0.2,16
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2020-10-16
  • Updated: 2020-10-20
  • Resolved: 2020-10-20
Related Reports
Relates :  
Description
After tzdata2020b, Formatter/Basic.java reports

FAILED: '%tZ': Expected 'PST', got 'MST'
FAILED: '%tZ': Expected 'PST', got 'MST'
FAILED: '%tZ': Expected 'PST', got 'MST'
FAILED: '%TZ': Expected 'PST', got 'MST'
FAILED: '%TZ': Expected 'PST', got 'MST'
FAILED: '%TZ': Expected 'PST', got 'MST'
FAILED: '%tc': Expected 'Tue May 23 19:48:34 PST 1995', got 'Tue May 23 19:48:34 MST 1995'
FAILED: '%tc': Expected 'Tue May 23 19:48:34 PST 1995', got 'Tue May 23 19:48:34 MST 1995'
FAILED: '%tc': Expected 'Tue May 23 19:48:34 PST 1995', got 'Tue May 23 19:48:34 MST 1995'
FAILED: '%Tc': Expected 'TUE MAY 23 19:48:34 PST 1995', got 'TUE MAY 23 19:48:34 MST 1995'
FAILED: '%Tc': Expected 'TUE MAY 23 19:48:34 PST 1995', got 'TUE MAY 23 19:48:34 MST 1995'
FAILED: '%Tc': Expected 'TUE MAY 23 19:48:34 PST 1995', got 'TUE MAY 23 19:48:34 MST 1995'
Exception in thread "main" java.lang.RuntimeException: 6313 tests: 12 failure(s), first
	at Basic.main(Basic.java:100)
Caused by: java.lang.RuntimeException: '%tZ': Expected 'PST', got 'MST'
	at Basic.setFirst(Basic.java:64)
	at Basic.fail(Basic.java:57)
	at Basic.ck(Basic.java:72)
	at BasicDateTime.test(BasicDateTime.java:54)
	at BasicDateTime.testDateTime(BasicDateTime.java:150)
	at BasicDateTime.testDateTime(BasicDateTime.java:141)
	at BasicDateTime.test(BasicDateTime.java:1658)
	at Basic.main(Basic.java:97)

for timezones - "America/Dawson", "America/WhiteHorse" and "Canada/Yukon".

Currently, a placeholder has been put in place so no failure is seen. But it should be investigated and fixed as the above-mentioned timezones move to MST only on 1 Nov 2020. 


Here is a simple test case :

import java.util.*;
import java.lang.*;

public class Basic {
    public static void main(String args[]) {
        SimpleTimeZone tz = new SimpleTimeZone(-8 * 60 * 60 * 1000, "America/Dawson");
        Calendar cl = new GregorianCalendar(tz, Locale.US);
        cl.set(2020,10,16, 19, 48, 34);
        cl.set(Calendar.MILLISECOND, 584);
        Formatter f = new Formatter(new StringBuilder(), Locale.US);
        f.format("%tZ", cl);
        System.out.println("Short name = " + f.toString());
    }
}
Comments
The workaround is to set provider to -Djava.locale.providers=CLDR when using the above zones for retrieving short names. With JRE provider, the display names are set to MST and are made available through resource bundles which are static and cannot be modified.
20-10-2020

The issue is seen in all releases for JRE provider as MST is returned despite the date/time, similarly, for CLDR provider PST is returned for all releases despite the date/time.
20-10-2020