Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get localized short day-in-week name (Mo/Tu/We/Th...)

Can I get localized short day-in-week name (Mo/Tu/We/Th/Fr/Sa/Su for English) in Java?

like image 346
fhucho Avatar asked Sep 24 '10 21:09

fhucho


People also ask

How do you get the day of the week from a date in Java?

To get the day of week for a particular date in Java, use the Calendar. DAY_OF_WEEK constant.

How to get day of week from Date in android studio?

get(Calendar. DAY_OF_WEEK); Just the same as in Java, nothing particular to Android. You can check that from Calender.

How to get day name from Localdate in Java?

// displaying full-day name f = new SimpleDateFormat("EEEE"); String str = f. format(new Date()); System. out. println("Full Day Name = "+str);


2 Answers

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  
like image 177
RealHowTo Avatar answered Sep 22 '22 19:09

RealHowTo


If standard abbreviations are fine with you, just use Calendar class like this:

myCal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US); 
like image 40
Drakanor Avatar answered Sep 19 '22 19:09

Drakanor