I am documenting some code and need help understanding this little line.
private Calendar cal = Calendar.getInstance();
if ((this.cal.get(7) != 7) || (this.cal.get(7) == 1)) {
What does cal.get(7)
mean? I ran it on an IDE, and it gave me a result of 5. I tried cal.get(6)
, and got a result of 169.
If "cal" is a java.util.Calendar, then 7 would be DAY_OF_WEEK. However, you shouldn't pass literal integers into the .get() method; use the constants on the Calendar class instead. So, for instance, this is the equivalent of your example:
(DAY_OF_YEAR has the value of 6, by the way)
The Calendar class has a large number of constants you can use; see the javadoc for more info.