Can I get localized short day-in-week name (Mo/Tu/We/Th/Fr/Sa/Su for English) in Java?
To get the day of week for a particular date in Java, use the Calendar. DAY_OF_WEEK constant.
get(Calendar. DAY_OF_WEEK); Just the same as in Java, nothing particular to Android. You can check that from Calender.
// displaying full-day name f = new SimpleDateFormat("EEEE"); String str = f. format(new Date()); System. out. println("Full Day Name = "+str);
The best way is with java.text.DateFormatSymbols
DateFormatSymbols symbols = new DateFormatSymbols(new Locale("it")); // for the current Locale : // DateFormatSymbols symbols = new DateFormatSymbols(); String[] dayNames = symbols.getShortWeekdays(); for (String s : dayNames) { System.out.print(s + " "); } // output : dom lun mar mer gio ven sab
If standard abbreviations are fine with you, just use Calendar class like this:
myCal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US);
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