java determines whether a date is a weekend:
/** * 判断是否是周末 * @return */ private boolean isWeekend(Calendar cal){ int week=cal.get(Calendar.DAY_OF_WEEK)-1; if(week ==6 || week==0){//0代表周日,6代表周六 return true; } return false; }
The Calendar class is an abstract class that provides us with related functions for date calculation, such as: year, month, Display and calculation of day, hour, minute and second.
GregorianCalendar is a concrete subclass of Calendar that provides the standard calendar system used by most countries in the world.
Calendar.DAY_OF_WEEK——The day of the week, the value of 1--7, corresponding to: Sunday, Monday, Tuesday, Wednesday....Saturday
Getting the day of the week Calendar.DAY_OF_WEEK - The reason for 1
Calendar.DAY_OF_WEEK in Java actually means: the day of the week, so it will be affected by the day of the week when the first day is.
Some areas use Sunday as the first day of the week, while some areas use Monday as the first day of the week. These two situations need to be distinguished.
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of Java determines whether a date is a weekend. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools