Calendar class getDisplayName(int field, int style, Locale locale) method example
Calendar class getDisplayName(int field, int style, Locale locale) method example. This example shows you how to use getDisplayName(int field, int style, Locale locale) method.This method Returns the string representation of the calendar field value in the given style and locale
Here is the code:-
/**
* @Program that Gets what the first day of the week is; e.g., SUNDAY in the
* U.S., MONDAY in France.
* getDisplayNamecalender.java
* Author:-RoseIndia Team
* Date:-22-May-2008
*/
import java.util.*;
public class getDisplayNamecalender {
public static void main(String[] args) {
//Creating calender
Calendar c=Calendar.getInstance();
int i = c.getFirstDayOfWeek();
System.out.print("The first day of the week is: ");
switch(i) {
case Calendar.SUNDAY:
System.out.println("Sunday");
break;
case Calendar.MONDAY:
System.out.println("Monday");
break;
case Calendar.TUESDAY:
System.out.println("Tuesday");
break;
case Calendar.WEDNESDAY:
System.out.println("Wednesday");
break;
case Calendar.THURSDAY:
System.out.println("Thursday");
break;
case Calendar.FRIDAY:
System.out.println("Friday");
break;
case Calendar.SATURDAY:
System.out.println("Saturday");
break;
default:
System.out.println("Invalid!");
}
}
} |
Output of the program:-
| The first day of the week is: Sunday |
|