Get an array of day names

 Problem:

You want to retrieve all of the day of the week names for a locale.

Solution:

The DateFormatSymbols class contains a wealth of information useful to the localization programmer.  You can easily retrieve day names, month names, era names, etc...

 

To get the days of the week in Korean and English:

//Get a DateFormatSymbols object using a locale as an argument

DateFormatSymbols dfsKorean = new DateFormatSymbols(Locale.KOREAN);

DateFormatSymbols dfsEnglish = new DateFormatSymbols(Locale.ENGLISH);

//Get an array of weekday names

String[] kWeekdays = dfsKorean.getWeekdays();

String[] eWeekdays = dfsEnglish.getWeekdays();

//Loop through the array and output the names

for(int x = 1; x < 8; x++){

    System.out.println(eWeekdays[x] + " = " + kWeekdays[x]);

}

 

 


The output:

Sunday = 일요일

Monday = 월요일

Tuesday = 화요일

Wednesday = 수요일

Thursday = 목요일

Friday = 금요일

Saturday = 토요일