Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java calendar weekend of current week

Java using calendar i want to get date of current weekend, any quick idea

like image 622
d-man Avatar asked Apr 15 '11 07:04

d-man


People also ask

How to check current Date is Weekend in Java?

Checking a Weekend using LocalDate The LocalDate. get(ChronoField. DAY_OF_WEEK) method returns an integer value in the range of 1 to 7. Each integer value represents a different weekday.

How to get week dates in Java?

Get the Day of Week using Calendar (Java 7)Calendar cal = Calendar. getInstance(); cal. setTime(new Date()); int dayOfWeekNum = cal. get(Calendar.

What is the use of calendar getInstance () in Java?

Calendar 's getInstance method returns a Calendar object whose calendar fields have been initialized with the current date and time: Calendar rightNow = Calendar.


1 Answers

Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
c.getTime(); // => Date of this coming Saturday.
like image 140
maerics Avatar answered Nov 09 '22 03:11

maerics