localization - How can I see each permutation of `FormatStyle` for a localized `DateTimeFormatter` in Java? -
i cannot find documentation particular behavior of formatstyle
set date portion , time portion of datetimeformatter
when automatically localizing:
datetimeformatter.oflocalizeddatetime(formatstyle datestyle, formatstyle timestyle)
is there way know possible variations of strings generated particular locale
?
if want know results of generated strings (the final result of format
method), your answer covers well. i'd add external loop through locales, because different locales can have different format styles.
if want know patterns, though, can use datetimeformatterbuilder.getlocalizeddatetimepattern
method within same nested loops. used values()
method instead of enumset
(not sure if makes difference):
for (locale locale : locale.getavailablelocales()) { system.out.println("--|for locale " + locale + "|-------"); (formatstyle styledate : formatstyle.values()) { (formatstyle styletime : formatstyle.values()) { string pattern = datetimeformatterbuilder.getlocalizeddatetimepattern(styledate, styletime, isochronology.instance, locale); int padspacesoutto = 17; string styles = styledate + " | " + styletime; string styleslabel = string.format("%1$-" + padspacesoutto + "s", styles); system.out.println(styleslabel + pattern); } } }
the output (depending on available locales in jvm) this:
--|for locale ar_ae|------- full | full dd mmmm, yyyy z hh:mm:ss full | long dd mmmm, yyyy z hh:mm:ss full | medium dd mmmm, yyyy hh:mm:ss full | short dd mmmm, yyyy hh:mm long | full dd mmmm, yyyy z hh:mm:ss long | long dd mmmm, yyyy z hh:mm:ss long | medium dd mmmm, yyyy hh:mm:ss long | short dd mmmm, yyyy hh:mm medium | full dd/mm/yyyy z hh:mm:ss medium | long dd/mm/yyyy z hh:mm:ss medium | medium dd/mm/yyyy hh:mm:ss medium | short dd/mm/yyyy hh:mm short | full dd/mm/yy z hh:mm:ss short | long dd/mm/yy z hh:mm:ss short | medium dd/mm/yy hh:mm:ss short | short dd/mm/yy hh:mm --|for locale ar_jo|------- full | full dd mmmm, yyyy z hh:mm:ss full | long dd mmmm, yyyy z hh:mm:ss full | medium dd mmmm, yyyy hh:mm:ss ... lots of output
Comments
Post a Comment