I am finding a solution to get very short week day names like Google Calendar App.
The below is what I tried:
String[] shortWeekDays = DateFormatSymbols.getInstance(Locale.getDefault()).getShortWeekdays();
The result is
Sun, Mon, Tue, Wed, Thu, Fri, Sat
Google Calendar (Very short week-day names)
S, M, T, W, T, F, S
I like to use Week-day names like Google calendar
Updated I was thinking about getting first letter of week-day names (after DateFormatSymbols.getShortWeekdays) BUT for some languages (Chinese, Singapore, Taiwan), the first letter are the same for all 7 week-days. See my below test
String[] weekDays = DateFormatSymbols.getInstance(Locale.CHINESE).getShortWeekdays();
// 星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六]
I am thinking about using String resources BUT my application support all languages around the world based on current locale used, it is hard for me to put all very short week-day names for All languages.
Anyone has ideas? Thank you!
After reviewed all locale available in Java and check their short week day names. I have my solution as below. It may help the others
For Locale: China-chinese, Singapore-Chinese, Taiwan-Chinese
For the rest Locales
The only solution I've seen for a one-character abbreviation for localized day names is the following:
DateUtils.getDayOfWeekString(dayOfWeek, DateUtils.LENGTH_SHORTEST)
Using DateFormatSymbols.getShortWeekdays
and then pulling characters off the front doesn't work in other locales. For instance in Arabic, doing that results in the same character for every single day of the week.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With