Is there a date format to display the day of the week in java?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Yes. In Java date formatting, the usual pattern letter for a weekday name is E. In modern Java, the best way to use it is through java.time.format.DateTimeFormatter, which is clearer and thread-safe compared with the older SimpleDateFormat API.
The Pattern Letter for Weekday Names
Java date patterns use E to represent the day of the week.
Common forms include:
- '
Efor a short name such asTue' - '
EEEEfor a full name such asTuesday' - '
EEEEEfor a narrow form in some locales'
A simple example with LocalDate:
That prints the weekday in full form in the first case and abbreviated form in the second.
Prefer DateTimeFormatter in New Code
For new Java code, DateTimeFormatter is the right default because it is immutable and thread-safe. It works naturally with modern Java time types such as:
- '
LocalDate' - '
LocalDateTime' - '
ZonedDateTime' - '
OffsetDateTime'
That makes it a better everyday choice than the older formatting classes.
Locale Changes the Weekday Text
Weekday names depend on locale. The same date can display different day names depending on which locale you use.
If the output is user-facing, set the locale intentionally instead of relying on the machine default.
Time Zone Can Change the Visible Day
If you are formatting an instant rather than a plain date, the chosen time zone may change the visible weekday. That matters for timestamps near midnight.
For reporting, notifications, and scheduling logic, this distinction is important. The day of week is not just a formatting question if the underlying moment is being viewed in different zones.
Legacy SimpleDateFormat Still Uses the Same Idea
Older Java code often uses SimpleDateFormat, and it uses the same E pattern.
This still works, but SimpleDateFormat is mutable and not thread-safe. For shared formatter usage in modern code, DateTimeFormatter is much safer.
Use DayOfWeek for Logic
Formatting is for presentation. If your program logic needs to know whether a date is Monday, Friday, or weekend, use structured date APIs rather than inspecting formatted strings.
For example, use date.getDayOfWeek() for logic and use DateTimeFormatter only when you are preparing text for output.
That keeps logic robust and localization-friendly.
Common Pitfalls
The most common mistake is using the wrong pattern letters and expecting a weekday name from something other than E.
Another pitfall is forgetting about locale and then getting different output on different environments. Developers also often ignore time zone when formatting instants near midnight, which can make the displayed weekday look “wrong” even though the formatter is behaving correctly.
Finally, avoid using formatted strings for weekday logic. Compare structured date values instead.
Summary
- Java uses
Eto format weekday names. - '
DateTimeFormatteris the recommended modern API for this task.' - Use
Efor short names andEEEEfor full names. - Set locale and time zone explicitly when the output must be stable.
- Use
DayOfWeekfor logic and formatted strings only for presentation.

