We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
To get the Day of Week from the given date, I have set the date using the the set method of the Calendar class.
The set method of a Calendar class has the following parameters
year - the value used to set the YEAR calendar field.
month - the value used to set the MONTH calendar field. Month value is 0-based. e.g., 0 for January.
date - the value used to set the DAY_OF_MONTH calendar field.
In the given problem, the input is 08 05 2015 which is explained as August 5th 2015, so here 08 means August. In general we do count the months from 1, i.e 1 for January, since the month parameter is 0-based we have to use the month-1.
Java Date and Time
You are viewing a single comment's thread. Return to all comments →
Hello @chhayaprakashj
To get the Day of Week from the given date, I have set the date using the the
set
method of theCalendar
class.The
set
method of aCalendar
class has the following parametersyear
- the value used to set the YEAR calendar field.month
- the value used to set the MONTH calendar field. Month value is 0-based. e.g., 0 for January.date
- the value used to set the DAY_OF_MONTH calendar field.In the given problem, the input is
08 05 2015
which is explained as August 5th 2015, so here08
means August. In general we do count the months from 1, i.e 1 for January, since themonth
parameter is 0-based we have to use themonth-1
.Read more about
Calendar
class at https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html