How to use java calendar to check whether today is Sunday
•
Java
I wrote a few lines of code that didn't work Why? Can you explain something?
Calendar date = Calendar.getInstance(); date.set(2010,03,7); if(date.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) System.out.println("OK");
Solution
To avoid errors, you can use the calendar static value of the month, for example:
date.set(2010,Calendar.MARCH,7);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码