am/pm strings not localized/translated when using DateFormat

不想你离开。 提交于 2019-12-06 06:12:42
kouretinho

After further investigation, I found a similar bug for Java 6, "Swedish localization has incorrect am/pm markers".The bug was reported back in 2007 and was finally resolved in 2011.

Also, according to the official Oracle page "The set of supported locales varies between different implementations of the Java Platform Standard Edition (Java SE)".

Testing my code on various devices I found out that it worked correctly on android 4.1.2 and 4.4, but the problem remains for my android 4.1.1 device. Given that old android's Java version is similar to Java 6 I infer that it's a Java language problem that is solved in newer versions.

Mani

I don't see an problem with your code.

    private static final Locale GREEK_LOCALE = new Locale("el", "GR");
    public static final DateFormat USER_DF_TIME = DateFormat.getDateTimeInstance(DateFormat.SHORT,
            DateFormat.SHORT,GREEK_LOCALE );
    String dateString =USER_DF_TIME.format(new java.util.Date());
    System.out.println(dateString);

Returning 15/5/2014 2:11 μμ properly ( I am in EST now)

Seems you have issues with default locale. Follow https://stackoverflow.com/a/4212671/2182351 to get correct locale

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