DateFormatSymbols getWeekdays() Method in Java with Examples
The getWeekdays() Method of DateFormatSymbols class in Java is used to get the name of the weekdays of the calendar in a string format.
Syntax:
public String[] getWeekdays()
Parameters: The method does not take any parameters.
Return Values: The method returns the name of the weekdays in a string format.
Below programs illustrate the use of getWeekdays() method.
Example 1:
// Java code to demonstrate getWeekdays() import java.text.DateFormatSymbols; public class DateFormat_Main { public static void main(String args[]) { int i; // Initializing DateFormatSymbols String wkdays[] = new DateFormatSymbols().getWeekdays(); for (i = 1; i < wkdays.length; i++) { // Displaying the weekdays System.out.println("Day " + i + " = " + wkdays[i]); } } } |
Day 1 = Sunday Day 2 = Monday Day 3 = Tuesday Day 4 = Wednesday Day 5 = Thursday Day 6 = Friday Day 7 = Saturday
Example 2:
// Java code to demonstrate getWeekdays() import java.text.DateFormatSymbols; public class DateFormat_Main { public static void main(String args[]) { int i; // Initializing DateFormatSymbols String wkdays[] = new DateFormatSymbols().getWeekdays(); for (i = 1; i < wkdays.length / 2; i++) { // Displaying the weekdays System.out.println("Day " + i + " = " + wkdays[i]); } } } |
Day 1 = Sunday Day 2 = Monday Day 3 = Tuesday
Reference: https://docs.oracle.com/javase/8/docs/api/java/text/DateFormatSymbols.html#getWeekdays–
Recommended Posts:
- DateFormatSymbols getShortMonths() Method in Java with Examples
- DateFormatSymbols getShortWeekdays() Method in Java with Examples
- DateFormatSymbols getAvailableLocales() Method in Java with Examples
- DateFormatSymbols getMonths() Method in Java with Examples
- DateFormatSymbols getEras() Method in Java with Examples
- DateFormatSymbols setWeekdays() Method in Java with Examples
- DateFormatSymbols setShortWeekdays() Method in Java with Examples
- DateFormatSymbols setShortMonths() Method in Java with Examples
- DateFormatSymbols getAmPmStrings() Method in Java with Examples
- DateFormatSymbols setMonths() Method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


