publicclass ExtensionsTest { publicstaticvoid main(String[] args) {
Locale jaJPJP = Locale.of("ja", "JP", "JP"); if (!jaJPJP.hasExtensions()) {
error(jaJPJP + " should have an extension.");
}
Locale stripped = jaJPJP.stripExtensions(); if (stripped.hasExtensions()) {
error(stripped + " should NOT have an extension.");
} if (jaJPJP.equals(stripped)) { thrownew RuntimeException("jaJPJP equals stripped");
} if (!"ja-JP-x-lvariant-JP".equals(stripped.toLanguageTag())) {
error("stripped.toLanguageTag() isn't ja-JP-x-lvariant-JP");
}
Locale enUSja = Locale.forLanguageTag("en-US-u-ca-japanese"); if (!enUSja.stripExtensions().equals(Locale.US)) {
error("stripped enUSja not equals Locale.US");
}
// If a Locale has no extensions, stripExtensions() returns self.
Locale enUS = Locale.US.stripExtensions(); if (enUS != Locale.US) {
error("stripped Locale.US != Locale.US");
}
}
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.