Reputation: 107
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 - android.text.format.DateUtils.formatDateTime android.text.format.DateFormat.getDateFormat
but couldn't get the result i wanted. Thanks
Upvotes: 0
Views: 970
Reputation: 881
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日
Upvotes: 1