Gregorian calendar returns an incorrect day in Java_ OF_ WEEK
•
Java
This Code:
Calendar calendar; calendar = GregorianCalendar.getInstance(); calendar.set(year,month,day); week_day = calendar.get(Calendar.DAY_OF_WEEK);
Returns an incorrect value
for example
Returns the same value
How can I do this correctly?
Solution
In Java, months start at 0
The 31st day of the third month is April 31. If that doesn't exist, it will be transferred to May 1,
The first day of the fourth month is May 1, the same day as the above
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
二维码