Search code examples
javalocalizationcalendarlocale

Can't get armenian months names


I want to print armenian month names but it doesn't work. This is my code:

Locale loc = new Locale("hy");
Calendar cal = Calendar.getInstance(loc);
System.out.println(cal.getDisplayName(Calendar.MONTH, Calendar.LONG_STANDALONE, loc));

I have tried many others abbreviation like "hye" or "arm", but nothing works. Other language such as russian "ru" work fine. I have no idee what i'm doing wrong


Solution

  • There was an enhancement in JDK8 wherein the CLDR's XML-based locale data has been incorporated into the JDK 8 release, however it is disabled by default. So, if you run your code with the argument -Djava.locale.providers=CLDR or add the same through the java.locale.providers System.property in your code, hy: Armenian hy_AM: Armenian will be supported.

    With JDK 9 enhancements , CLDR locale data is enabled by default. So, the code will run without adding any system property. Hope this helps.