gga gga - 4 months ago 14x
Android Question

Date with format and locale

I am trying to get the date with this pattern - "dd/MM/yyyy".
So far i've used SimpleDateFormat to achieve it, but now i need to also support Chinese in my app and it's not giving me the result i need.

I'm trying to make it look like the pattern with attention to the locale:
English: 16/05/2016
Chinese: 2016年05月16日

I tried different options -

but couldn't get the result i wanted.


If you want specific patterns, you have to test the locale and apply the format you want.

For your english and chinese formats :

CharSequence englishDate = DateFormat.format("dd/MM/yyyy", date);
CharSequence chineseDate = DateFormat.format("yyyy年MM月dd日", date);

Results are : 25/05/2016 and 2016年05月25日