< prev index next >

test/java/util/Calendar/SupplementalJapaneseEraTest.java

Print this page
rev 16588 : [mq]: 8173423

*** 1,7 **** /* ! * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,31 **** --- 20,33 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ import java.text.SimpleDateFormat; + import java.time.chrono.JapaneseChronology; import java.time.chrono.JapaneseDate; import java.time.chrono.JapaneseEra; + import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import static java.util.GregorianCalendar.*;
*** 120,130 **** // test era abbreviation sdf = new SimpleDateFormat("G y-MM-dd", WAREKI_LOCALE); got = sdf.format(firstDayOfEra); expected = NEW_ERA_ABBR+" 1-02-11"; if (!expected.equals(got)) { ! System.err.printf("GGGG y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); errors++; } // confirm the gregorian year sdf = new SimpleDateFormat("y", Locale.US); --- 122,132 ---- // test era abbreviation sdf = new SimpleDateFormat("G y-MM-dd", WAREKI_LOCALE); got = sdf.format(firstDayOfEra); expected = NEW_ERA_ABBR+" 1-02-11"; if (!expected.equals(got)) { ! System.err.printf("G y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); errors++; } // confirm the gregorian year sdf = new SimpleDateFormat("y", Locale.US);
*** 161,170 **** --- 163,186 ---- got = jera.getDisplayName(TextStyle.NARROW_STANDALONE, Locale.US); if (!NEW_ERA_ABBR.equals(got)) { System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); errors++; } + + // test long/abbreviated names with java.time.format + got = new DateTimeFormatterBuilder() + .appendPattern("GGGG") + .appendLiteral(" ") + .appendPattern("G") + .toFormatter(Locale.US) + .withChronology(JapaneseChronology.INSTANCE) + .format(jdate); + expected = NEW_ERA_NAME + " " + NEW_ERA_ABBR; + if (!expected.equals(got)) { + System.err.printf("java.time formatter long/abbr names: got=\"%s\", expected=\"%s\"%n", got, expected); + errors++; + } } private static void testValidation(String eraName) { Calendar jcal = new Calendar.Builder() .setCalendarType("japanese")
< prev index next >