Java Date Time - Java Calendar DAY_OF_WEEK








Syntax

Calendar.DAY_OF_WEEK has the following syntax.

public static final int DAY_OF_WEEK

Example

In the following code shows how to use Calendar.DAY_OF_WEEK field.

import java.util.Calendar;
// w  w w.  j a v  a2  s.co m
public class Main {
  public static void main(String[] args) {
    Calendar now = Calendar.getInstance();
    String[] strDays = new String[] { "Sunday", "Monday", "Tuesday",
        "Wednesday", "Thusday", "Friday", "Saturday" };
    System.out.println("Current day is : "
        + strDays[now.get(Calendar.DAY_OF_WEEK) - 1]);
  }
}

The output: