Localize string from `MonthDay` or `YearMonth` classes in java.time? [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-11-29 12:51:36

See JDK-8168532. There needs an enhancement in the JDK to make this easy.

It is possible to do the work outside the JDK, but it is a lot of work. You have to parse the CLDR XML files (which are interlinked and have many references). Then you extract the relevant localized patterns for MonthYear and YearMonth, Then those patterns can be used to create a DateTimeFormatter.

Alternatively, you can hard code a map - Map<Locale, DateTimeFormatter> - based on your business needs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!