Android Ukrainian

How can I dynamically convert Date to Ukrainian?

I am using this code:

 final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM, yyyy"); final Date date = calendar.getTime(); final TextView chosenMonth = (TextView) findViewById(R.id.chosenMonth); chosenMonth.setText(dateFormat.format(date)); 

Format the date as "September 2013." This text language is the language of the device, but I need to format this date and display only in Ukrainian.

I tried to implement this using the Locale class, but there is no constant for the UA language.

+4
source share
2 answers

Although there is no constant, you can set the locale yourself if it is supported on your device. Refer to this list of supported locales for the Android version .

Create your Ukrainian language using new Locale('uk','UA') , and then use it in the version of SimpleDateFormat, which occupies the locale.

Will this work?

 final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM, yyyy", new Locale('uk','UA')); 
+4
source

Try using DateFormat.getDateInstance(int style, Locale locale) instead of creating your own templates using SimpleDateFormat.

0
source

Source: https://habr.com/ru/post/1500195/


All Articles