Java DayOfWeek Enum: Methods, Day Names and Examples

Learn the Java DayOfWeek enum with getValue() vs ordinal(), day names in every style, parsing text, EnumSet, week start per locale and adjusters.

The seven DayOfWeek constants with their getValue numbers 1 to 7, ordinal positions 0 to 6, and plus and minus wrapping around the week

The java.time.DayOfWeek enum represents the seven days of the week, from MONDAY to SUNDAY, and gives each day an ISO-8601 number from 1 to 7 through getValue(). Every date class in java.time returns a DayOfWeek from getDayOfWeek(), so the enum is the type we work with whenever a rule depends on the weekday.

We use DayOfWeek for opening hours, recurring meetings, weekend surcharges and calendar headers. The enum also does the arithmetic and the localized names for us, so we never keep our own arrays of day names or numbers.

The following example creates a day from its number, moves it forward, prints its names and parses it back from text.

DayOfWeek day = DayOfWeek.of(5);                                   // FRIDAY
int iso = day.getValue();                                          // 5
DayOfWeek inThreeDays = day.plus(3);                               // MONDAY
String full = day.getDisplayName(TextStyle.FULL, Locale.US);       // "Friday"
String shortName = day.getDisplayName(TextStyle.SHORT, Locale.US); // "Fri"
DayOfWeek fromName = DayOfWeek.valueOf("FRIDAY");                  // FRIDAY
boolean weekend = day.getValue() >= 6;                             // false

Notice that plus(3) wraps from Friday past Sunday to Monday without any modulo arithmetic. We go through the numbers behind each constant, day names in every style and language, parsing user text, sets and maps of days, the first day of the week per locale, and moving a date to a given weekday. A gym timetable ties it together at the end.

1. DayOfWeek Enum Constants, Numbers and Arithmetic

The DayOfWeek enum declares its constants in ISO order, so MONDAY comes first and SUNDAY last. Each constant carries two numbers, and only one of them is meant for our code. We read the ISO day number, 1 for Monday up to 7 for Sunday, with getValue(), while ordinal() counts enum positions starting at 0.

The seven DayOfWeek constants with their getValue numbers 1 to 7, ordinal positions 0 to 6, and plus and minus wrapping around the week
getValue() counts from 1 for Monday, ordinal() counts from 0, and plus() and minus() wrap around the week
DayOfWeek[] week = DayOfWeek.values();                // [MONDAY, TUESDAY, ..., SUNDAY]
int days = week.length;                               // 7
int sundayValue = DayOfWeek.SUNDAY.getValue();        // 7
int sundayOrdinal = DayOfWeek.SUNDAY.ordinal();       // 6
DayOfWeek back = DayOfWeek.MONDAY.minus(1);           // SUNDAY
DayOfWeek far = DayOfWeek.MONDAY.plus(15);            // TUESDAY
DayOfWeek negative = DayOfWeek.SUNDAY.plus(-1);       // SATURDAY
DayOfWeek bad = DayOfWeek.of(8);                      // DateTimeException: Invalid value for DayOfWeek: 8

The ordinal() method is not the numeric value of a day, so we store and compare getValue() or the constant itself. The plus() and minus() methods accept any long, including negative numbers and values larger than 7, and they always land on a valid day.

Because DayOfWeek is an enum, it is immutable and thread-safe, two constants compare with ==, and compareTo() follows the Monday-to-Sunday order. The enum has no isBefore() method, so a check such as “is this day before Friday” uses compareTo() or getValue().

boolean before = DayOfWeek.TUESDAY.compareTo(DayOfWeek.FRIDAY) < 0;   // true
boolean same = DayOfWeek.of(7) == DayOfWeek.SUNDAY;                     // true
int gap = DayOfWeek.FRIDAY.getValue() - DayOfWeek.TUESDAY.getValue();   // 3

2. Day Names in Full, Short and Narrow Form

The method getDisplayName(TextStyle, Locale) returns the name of the day in the language of the locale. The TextStyle argument picks the length. A calendar header on a phone has room for one letter, whereas an email has room for the full word.

DayOfWeek day = DayOfWeek.WEDNESDAY;
String full = day.getDisplayName(TextStyle.FULL, Locale.US);         // "Wednesday"
String abbr = day.getDisplayName(TextStyle.SHORT, Locale.US);        // "Wed"
String letter = day.getDisplayName(TextStyle.NARROW, Locale.US);     // "W"
String german = day.getDisplayName(TextStyle.FULL, Locale.GERMAN);   // "Mittwoch"
String french = day.getDisplayName(TextStyle.SHORT, Locale.FRENCH);  // "mer."
String constant = day.toString();                                    // "WEDNESDAY"

Two details matter in a UI. Narrow names repeat in English, where Saturday and Sunday share the letter “S”, so a one-letter header needs its column position to tell the days apart. French and many other languages write day names in lowercase, so we capitalize at the start of a sentence instead of assuming the JDK did.

We pass an explicit Locale in server code. The default locale of a container is often en_US or the plain root locale, and the names change when the app moves to another machine. The day name display examples cover formatter patterns such as EEEE for a whole date.

3. Turning Text Into a DayOfWeek

A day often arrives as text, for example from a query parameter, a CSV column or a cron-like setting. The method valueOf() accepts only the constant name in uppercase, so “Friday” and “FRI” both fail with an IllegalArgumentException.

DayOfWeek upper = DayOfWeek.valueOf("FRIDAY");                  // FRIDAY
DayOfWeek mixed = DayOfWeek.valueOf("Friday");                  // IllegalArgumentException: No enum constant java.time.DayOfWeek.Friday
DayOfWeek fixed = DayOfWeek.valueOf("friday".toUpperCase(Locale.ROOT));   // FRIDAY

For real names and abbreviations, a DateTimeFormatter with the pattern EEEE (full) or EEE (short) parses the text, and DayOfWeek.from() reads the day out of the parsed result. The formatter also understands other languages when we give it the matching locale.

DateTimeFormatter fullNames = DateTimeFormatter.ofPattern("EEEE", Locale.US);
DateTimeFormatter shortNames = DateTimeFormatter.ofPattern("EEE", Locale.US);
DayOfWeek fromFull = DayOfWeek.from(fullNames.parse("Friday"));      // FRIDAY
DayOfWeek fromShort = DayOfWeek.from(shortNames.parse("Fri"));       // FRIDAY
DateTimeFormatter germanNames = DateTimeFormatter.ofPattern("EEEE", Locale.GERMAN);
DayOfWeek fromGerman = DayOfWeek.from(germanNames.parse("Montag"));  // MONDAY

User input can be blank, misspelled or in the wrong case. The helper method matches the full or the short English name in any case and returns an empty Optional instead of throwing.

static Optional<DayOfWeek> parseDay(String text) {
    if (text == null || text.isBlank()) {
        return Optional.empty();
    }
    String key = text.strip().toLowerCase(Locale.ROOT);
    for (DayOfWeek d : DayOfWeek.values()) {
        if (d.getDisplayName(TextStyle.FULL, Locale.US).toLowerCase(Locale.ROOT).equals(key)
                || d.getDisplayName(TextStyle.SHORT, Locale.US).toLowerCase(Locale.ROOT).equals(key)) {
            return Optional.of(d);
        }
    }
    return Optional.empty();
}
Optional<DayOfWeek> one = parseDay(" friday ");     // Optional[FRIDAY]
Optional<DayOfWeek> two = parseDay("SAT");           // Optional[SATURDAY]
Optional<DayOfWeek> three = parseDay("Fryday");      // Optional.empty
Optional<DayOfWeek> four = parseDay(null);           // Optional.empty

4. EnumSet and EnumMap for Groups of Days

Business rules rarely care about one day. They care about “weekdays”, “Tuesday and Thursday” or “every day except Sunday”. An EnumSet stores such a group as a bit mask, keeps the days in Monday-to-Sunday order and answers contains() in constant time.

Set<DayOfWeek> weekdays = EnumSet.range(DayOfWeek.MONDAY, DayOfWeek.FRIDAY);   // [MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY]
Set<DayOfWeek> weekend = EnumSet.complementOf(EnumSet.range(DayOfWeek.MONDAY, DayOfWeek.FRIDAY));   // [SATURDAY, SUNDAY]
Set<DayOfWeek> classDays = EnumSet.of(DayOfWeek.THURSDAY, DayOfWeek.TUESDAY);   // [TUESDAY, THURSDAY]
boolean saturdayClass = classDays.contains(DayOfWeek.SATURDAY);                  // false

Notice that classDays prints Tuesday first even though we passed Thursday first, because an EnumSet always iterates in declaration order. Weekend rules differ by country, for example Friday and Saturday in several Middle Eastern countries, so a configurable EnumSet is safer than a hard-coded getValue() >= 6 check. The weekend check examples compare both approaches.

An EnumMap maps each day to a value, such as the opening hours of a shop. Like the set, it keeps the keys in week order, which is the order a “store hours” box on a website needs.

Map<DayOfWeek, String> hours = new EnumMap<>(DayOfWeek.class);
hours.put(DayOfWeek.SATURDAY, "10-14");
hours.put(DayOfWeek.MONDAY, "9-18");
hours.put(DayOfWeek.FRIDAY, "9-20");
String keys = hours.keySet().toString();                              // "[MONDAY, FRIDAY, SATURDAY]"
String sunday = hours.getOrDefault(DayOfWeek.SUNDAY, "closed");      // "closed"

5. Which Day Starts the Week

The DayOfWeek enum always starts with Monday, as ISO-8601 does. Many countries, including the United States and Canada, show Sunday as the first column of a calendar, and some show Saturday. The class WeekFields knows the first day of the week for each locale.

DayOfWeek us = WeekFields.of(Locale.US).getFirstDayOfWeek();               // SUNDAY
DayOfWeek germany = WeekFields.of(Locale.GERMANY).getFirstDayOfWeek();     // MONDAY
DayOfWeek iso = WeekFields.ISO.getFirstDayOfWeek();                        // MONDAY

A calendar widget builds its header row from that first day. Since plus() wraps around the week, seven calls starting at the locale’s first day give the right column order for any locale.

static List<String> headerRow(Locale locale) {
    DayOfWeek first = WeekFields.of(locale).getFirstDayOfWeek();
    List<String> row = new ArrayList<>();
    for (int i = 0; i < 7; i++) {
        row.add(first.plus(i).getDisplayName(TextStyle.SHORT, locale));
    }
    return row;
}
List<String> usRow = headerRow(Locale.US);           // [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
List<String> ukRow = headerRow(Locale.UK);           // [Mon, Tue, Wed, Thu, Fri, Sat, Sun]

The localized number of a day follows the same rule. With WeekFields.of(Locale.US), Sunday is day 1, whereas getValue() keeps Sunday at 7 everywhere, which is why APIs and databases are better off with the ISO value or the constant name.

6. Moving a Date to a Given Weekday

Scheduling code asks questions such as “when is the next Monday” or “what is the second Tuesday of the month”. The TemporalAdjusters class answers them with a DayOfWeek argument, and LocalDate.with() applies the adjuster. October 10, 2026, our start date, is a Saturday.

LocalDate start = LocalDate.of(2026, 10, 10);                                        // a Saturday
LocalDate nextMonday = start.with(TemporalAdjusters.next(DayOfWeek.MONDAY));         // 2026-10-12
LocalDate sameOrNext = start.with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY)); // 2026-10-10
LocalDate lastFriday = start.with(TemporalAdjusters.previous(DayOfWeek.FRIDAY));     // 2026-10-09
LocalDate secondTuesday = start.with(TemporalAdjusters.dayOfWeekInMonth(2, DayOfWeek.TUESDAY));   // 2026-10-13
LocalDate lastFridayOfMonth = start.with(TemporalAdjusters.lastInMonth(DayOfWeek.FRIDAY));       // 2026-10-30

A DayOfWeek is itself an adjuster, so date.with(DayOfWeek.MONDAY) compiles too. It does not mean “next Monday”. It moves the date to the Monday of the same Monday-to-Sunday week, which for a Sunday is six days back.

LocalDate sunday = LocalDate.of(2026, 10, 11);
LocalDate sameWeekMonday = sunday.with(DayOfWeek.MONDAY);                        // 2026-10-05
LocalDate followingMonday = sunday.with(TemporalAdjusters.next(DayOfWeek.MONDAY));   // 2026-10-12

When we mean the coming Monday, we write TemporalAdjusters.next() or nextOrSame() so the code says what it does. To find week boundaries, the tutorial on the first and last day of the week uses previousOrSame() and nextOrSame().

7. Counting Weekdays Between Two Dates

Payroll and delivery estimates count weekdays, not calendar days. The method LocalDate.datesUntil() (Java 9) streams every date in a range, and a filter on the day of the week keeps Monday to Friday. The end date is exclusive.

Set<DayOfWeek> workDays = EnumSet.range(DayOfWeek.MONDAY, DayOfWeek.FRIDAY);
LocalDate from = LocalDate.of(2026, 10, 1);
LocalDate to = LocalDate.of(2026, 11, 1);
long weekdaysInOctober = from.datesUntil(to).filter(d -> workDays.contains(d.getDayOfWeek())).count();   // 22
long mondays = from.datesUntil(to).filter(d -> d.getDayOfWeek() == DayOfWeek.MONDAY).count();             // 4

The stream visits every date, which is fine for ranges of months or a few years. Holidays need their own set of dates on top of the weekday filter, as the business days calculation shows.

8. Building a Gym Class Timetable

Say a gym app runs a spin class every Tuesday and Thursday and a yoga class every Saturday. When a member opens the app, it lists the next three spin sessions after today. The class days live in an EnumSet, and the code walks forward from the given date.

static List<LocalDate> nextSessions(LocalDate today, Set<DayOfWeek> days, int count) {
    if (days.isEmpty()) {
        throw new IllegalArgumentException("No class days");
    }
    List<LocalDate> result = new ArrayList<>();
    LocalDate date = today;
    while (result.size() < count) {
        date = date.plusDays(1);
        if (days.contains(date.getDayOfWeek())) {
            result.add(date);
        }
    }
    return result;
}
Set<DayOfWeek> spin = EnumSet.of(DayOfWeek.TUESDAY, DayOfWeek.THURSDAY);
LocalDate today = LocalDate.of(2026, 10, 10);
List<LocalDate> sessions = nextSessions(today, spin, 3);                                   // [2026-10-13, 2026-10-15, 2026-10-20]
String label = sessions.get(0).getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.US);   // "Tue"

A real app reads the date from LocalDate.now(zone) with the gym’s time zone, so a member who opens the app at 23:30 sees the same list as the front desk. The method rejects an empty set first, because the loop in nextSessions() would never end without a class day. For the wider picture of reading a weekday from dates, zones and strings, see finding the day of the week from a date.

9. DayOfWeek FAQs

The numbering of the enum causes the most confusion, followed by storing a day and switching over it.

9.1. Is Monday 1 or 0 in Java DayOfWeek?

Monday is 1 when we call getValue(), and Sunday is 7. The method ordinal() returns 0 for Monday because it counts enum positions, so we never use it as a day number.

9.2. Does Java start the week on Sunday in the US?

The DayOfWeek enum always starts on Monday. Locale-aware code asks WeekFields.of(Locale.US).getFirstDayOfWeek(), which returns SUNDAY, and builds calendars or week numbers from that, as in section 5.

9.3. How do we store a DayOfWeek in a database?

We store the constant name, such as TUESDAY, or the ISO number from getValue(). With JPA, @Enumerated(EnumType.STRING) stores the name. The default EnumType.ORDINAL stores 0 to 6, which breaks the meaning of the column for anyone who expects ISO numbers.

9.4. Can we use DayOfWeek in a switch?

Yes. A switch expression over all seven constants needs no default, and the compiler reports a missing day.

static int surchargePercent(DayOfWeek day) {
    return switch (day) {
        case MONDAY, TUESDAY, WEDNESDAY, THURSDAY -> 0;
        case FRIDAY -> 10;
        case SATURDAY, SUNDAY -> 20;
    };
}
int friday = surchargePercent(DayOfWeek.FRIDAY);    // 10
int sunday = surchargePercent(DayOfWeek.SUNDAY);    // 20

10. Conclusion

The DayOfWeek enum holds the seven days in ISO order. We read the number with getValue(), move between days with plus() and minus(), and get localized names in three lengths from getDisplayName().

Text becomes a DayOfWeek through valueOf() for constant names or a formatter for real names. Groups of days belong in an EnumSet, per-day values in an EnumMap, and WeekFields tells us on which day a locale starts its week. To jump to a weekday, we use TemporalAdjusters and keep in mind that with(DayOfWeek) stays inside the same week. Related tutorials are listed in the Java date and time guide.

11. References

Happy Learning !!

Source Code on Github

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.