8190748: java/text/Format/DateFormat/DateFormatTest.java and NonGregorianFormatTest fail intermittently

Reviewed-by: rriggs, joehw, lancea
This commit is contained in:
Naoto Sato 2021-11-30 22:41:36 +00:00
parent 2942646957
commit f1c20e91d8
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,7 @@
/** /**
* @test * @test
* @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571 * @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571
* 8216969 * 8190748 8216969
* @summary test DateFormat and SimpleDateFormat. * @summary test DateFormat and SimpleDateFormat.
* @library /java/text/testlib * @library /java/text/testlib
* @modules jdk.localedata * @modules jdk.localedata
@ -342,7 +342,7 @@ public class DateFormatTest extends IntlTest
// Test pattern with runs things together // Test pattern with runs things together
public void TestRunTogetherPattern985() public void TestRunTogetherPattern985()
{ {
String format = "yyyyMMddHHmmssSSS"; String format = "yyyyMMddHHmmssSSSzzzz";
String now, then; String now, then;
SimpleDateFormat formatter = new SimpleDateFormat(format); SimpleDateFormat formatter = new SimpleDateFormat(format);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,13 @@
/* /*
* @test * @test
* @bug 4833268 6253991 8008577 * @bug 4833268 6253991 8008577 8190748
* @summary Test formatting and parsing with non-Gregorian calendars * @summary Test formatting and parsing with non-Gregorian calendars
* @modules jdk.localedata * @modules jdk.localedata
* @run main/othervm -Djava.locale.providers=COMPAT,SPI NonGregorianFormatTest * @run main/othervm -Djava.locale.providers=COMPAT,SPI NonGregorianFormatTest
*/ */
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.text.*; import java.text.*;
import static java.util.Calendar.*; import static java.util.Calendar.*;
@ -160,10 +161,15 @@ public class NonGregorianFormatTest {
private static void testRoundTrip(DateFormat df, Date orig) { private static void testRoundTrip(DateFormat df, Date orig) {
try { try {
var defZone = ZoneId.systemDefault();
if (defZone.getRules().getTransition(orig.toInstant().atZone(defZone).toLocalDateTime()) != null) {
System.out.println("At the offset transition. Round trip test skipped.");
return;
}
String s = df.format(orig); String s = df.format(orig);
Date parsed = df.parse(s); Date parsed = df.parse(s);
if (!orig.equals(parsed)) { if (!orig.equals(parsed)) {
error("testRoundTrip: bad date: origianl: '%s', parsed '%s'%n", orig, parsed); error("testRoundTrip: bad date: original: '%s', parsed '%s'%n", orig, parsed);
} }
} catch (Exception e) { } catch (Exception e) {
error("Unexpected exception: %s%n", e); error("Unexpected exception: %s%n", e);