The example code below helps you to get all weekday names as an array of string. The first method, getWeekdays()
return the full name string while the second method getShortWeekdays()
return the short name of the weekday.
package org.kodejava.text;
import java.text.DateFormatSymbols;
public class WeekdayNames {
public static void main(String[] args) {
DateFormatSymbols dfs = new DateFormatSymbols();
String[] weekdays = dfs.getWeekdays();
for (String weekday : weekdays) {
System.out.println("weekday = " + weekday);
}
String[] shortWeekdays = dfs.getShortWeekdays();
for (String shortWeekday : shortWeekdays) {
System.out.println("shortWeekday = " + shortWeekday);
}
}
}
The results of the code above are:
weekday =
weekday = Sunday
weekday = Monday
weekday = Tuesday
weekday = Wednesday
weekday = Thursday
weekday = Friday
weekday = Saturday
shortWeekday =
shortWeekday = Sun
shortWeekday = Mon
shortWeekday = Tue
shortWeekday = Wed
shortWeekday = Thu
shortWeekday = Fri
shortWeekday = Sat
Latest posts by Wayan (see all)
- How do I create a table with multiple header in iText 8? - March 16, 2024
- How do I add Image to a Table in iText 8? - March 11, 2024
- How do I downgrade Android SDK emulator version? - February 12, 2024