/** *teststhateranamesretrievedfromCalendar.getDisplayNamesmapshould *matchwiththatofEranamesretrievedfromDateFormatSymbols.getEras() *methodforallGregorianCalendarlocales.
*/ publicstaticvoid testEraName() {
Set<Locale> allLocales = Set.of(Locale.getAvailableLocales());
Set<Locale> JpThlocales = Set.of(
Locale.of("th", "TH"), Locale.forLanguageTag("th-Thai-TH"),
Locale.of("ja", "JP", "JP"), Locale.of("th", "TH", "TH")
);
Set<Locale> allLocs = new HashSet<>(allLocales); // Removing Japanese and Thai Locales to check Gregorian Calendar Locales
allLocs.removeAll(JpThlocales);
allLocs.forEach((locale) -> {
Calendar cal = Calendar.getInstance(locale);
Map<String, Integer> names = cal.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, locale);
DateFormatSymbols symbols = new DateFormatSymbols(locale);
String[] eras = symbols.getEras(); for (String era : eras) { if (!names.containsKey(era)) {
reportMismatch(names.keySet(), eras, locale);
}
}
});
}
privatestaticvoid reportMismatch(Set<String> CalendarEras, String[] dfsEras, Locale locale) {
System.out.println("For Locale " + locale + "era names in calendar map are " + CalendarEras); for (String era : dfsEras) {
System.out.println("For Locale " + locale + " era names in DateFormatSymbols era array are " + era);
} thrownew RuntimeException(" Era name retrieved from Calendar class do not match with"
+ " retrieved from DateFormatSymbols for Locale " + locale);
}
/** *teststhatErasnamesreturnedfromDateFormatSymbols.getEras() *andCalendar.getDisplayNames()shouldnotbeemptyforanyLocale.
*/ privatestaticvoid testEmptyEraNames() {
Set<Locale> allLocales = Set.of(Locale.getAvailableLocales());
allLocales.forEach((loc) -> {
DateFormatSymbols dfs = new DateFormatSymbols(loc);
Calendar cal = Calendar.getInstance(loc);
Map<String, Integer> names = cal.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, loc);
Set<String> CalendarEraNames = names.keySet();
String[] eras = dfs.getEras(); for (String era : eras) { if (era.isEmpty()) { thrownew RuntimeException("Empty era names retrieved for DateFomatSymbols.getEras"
+ " for locale " + loc);
}
}
CalendarEraNames.stream().filter((erakey) -> (erakey.isEmpty())).forEachOrdered((l) -> { thrownew RuntimeException("Empty era names retrieved for Calendar.getDisplayName"
+ " for locale " + loc);
});
});
privatestaticvoid checkPresenceCompat(String testName, Locale[] got) {
List<Locale> gotLocalesList = Arrays.asList(got);
Locale nb = Locale.forLanguageTag("nb"); if (!gotLocalesList.contains(nb)) { thrownew RuntimeException("Locale nb not supported by JREProvider for "
+ testName + " test ");
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.