简体   繁体   中英

Changing format of predefined java date formatters

Is there a way to change format of date (pattern) which is used by class DateFormat to print dates for specific locale?

Let me explain the situation I'm in. I have a big web application that runs on some proprietary server (IBM Domino) based on java ( version 1.6 + custom jsf 1.1 implementation). This app uses some out-of-the-box components that cannot be altered. Those components use DateFormat internally to display nice dates on some pages.

They are multilingual and in most of the languages the date format used is ok. But there is one language for which wrong format is used (at least in some sense - there is no official standard so some major organizations choose different formats for themselfs).

So, is there a chance that there is configuration for this or is it simply hardcoded somewhere in java standard library and cannot be altered?

Implement an instance of DateFormatProvider , create the file META-INF/services/java.text.spi.DateFormatProvider and put the fully qualified name of your implementation into it.
Package as jar, put the jar into the classpath and you "own" the DateFormat .

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM