Java DayOfWeek enum

Introduction

Java DayOfWeek enum represents seven days of the week.

The constants are

  • MONDAY
  • TUESDAY
  • WEDNESDAY
  • THURSDAY
  • FRIDAY
  • SATURDAY
  • SUNDAY

Java DayOfWeek enum getValue() method returns an int value: 1 for Monday, 2 for Tuesday, and so on.

import java.time.DayOfWeek;

public class Main {
  public static void main(String[] args) {
    // Obtain a DayOfWeek instance using an int value
    DayOfWeek d = DayOfWeek.of(7); // SUNDAY
    System.out.println(d);//from  w  ww . j  av  a 2 s .  c  o m

  }
}



PreviousNext

Related