- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check whether the given date represents weekend in Java
At first, display the current date:
LocalDate date = LocalDate.now();
Now, get the day of week from the above Date (current date):
DayOfWeek day = DayOfWeek.of(date.get(ChronoField.DAY_OF_WEEK));
On the basis of the above result, use SWITCH to check for the current day. If the day is SATURDAY/SUNDAY, then it’s Weekend.
Example
import java.time.DayOfWeek; import java.time.temporal.ChronoField; import java.time.LocalDate; public class Demo { public static void main(String[] argv) { LocalDate date = LocalDate.now(); DayOfWeek day = DayOfWeek.of(date.get(ChronoField.DAY_OF_WEEK)); switch (day) { case SATURDAY: System.out.println("Weekend - Saturday"); case SUNDAY: System.out.println("Weekend - Sunday"); default: System.out.println("Not a Weekend"); } } }
Output
Not a Weekend
- Related Articles
- How to determine if date is weekend in JavaScript?
- Java Program to Check Whether the Given String is Pangram
- How to check whether a JavaScript date is valid?
- Determine whether the given object represents a scalar data-type in Python
- Check whether the given file is an existing file in Java
- Java program to check whether the given number is an Armstrong number
- How to check whether element is in the array in Java?
- How to check whether the given strings are isomorphic using C#?
- Java program to check whether a given string is Heterogram or not
- How to check whether a binary tree has the given path sum in C#?
- Golang Program to Check Whether the Given String is Pangram
- How to check whether the given matrix is a Toeplitz matrix using C#?
- Queries to check whether a given digit is present in the given Range in C++
- How to Check if the Given Arrays are Disjoint in Java?
- Check if the current date falls in a given date range using MySQL query

Advertisements