calendar - DAY_OF_WEEK always returns 7 in Java GregorianCalendar -
So I want to do something with the Java Gregorian calendar, which seems as hard as me, from the month and date to the day of the week want to meet. But it will not do this, I know that people often get the wrong answer because they do not know that the number is going to be numbered 0, while DAY_OF_WEEK is being counted as 1 (and more). But it is DAY_OF_WEEK always my problem is my problem, always, 7 returns, no matter what I set the date when I Gregorian calendar converts the string, then appears as DAY_OF_WEEK Is it, even though I have set the year, month and month of the month
Where such a code is happening:
Gregorian calendar The date; Public overview (date, month, day, month, hour, minute, second); (Real old, brick month, Deofmonth Int, Int hour, intestine minutes, Int sec) {The date = new Gregoriyn calendar theDate.setFirstDayOfWeek (GregorianCalendar.SUNDAY); System.out.println ("DAY_OF_WEEK =" + theDate.DAY_OF_WEEK); Println (theDate.toString ()); }
calls that code:
Unrecognized current date = new observable date (2001, 3, 24, 9, 00, 00) ;
Output:
DAY_OF_WEEK = 7 java.util.GregorianCalendar [time =?, AreFieldsSet = false, areAllFieldsSet = false, liberal = true; zone = sun.util.calendar.ZoneInfo [id = "America / New_York", offset = -18000000, dstSavings = 3600000, useDaylight = true, transition = 235, lastRule = java.util.SimpleTimeZone [id = America / New_York, offset = - 18000000, dstSavings = 3600000, useDaylight true =, startYear = 0, Startmod = 3, startMonth = 2, startDay = 8, startDayOfWeek = 1, STARTTIME = 7200000, startTimeMode = 0, endMode = 3, endMonth = 10, endDay = 1, endDayOfWeek = 1, eNDTIME = 7200000, endTimeMode = 0]], firstDayOfWeek = 1, minimalDaysInFirstWeek = 1, age =? year = 2001 month = 3, WEEK_OF_YEAR =?, WEEK_OF_MONTH =?, DAY_OF_MONTH = 24, DAY_OF_YEAR =? DAY_OF_WEEK =?, DAY_OF_WEEK_IN_MONTH =?, AM_PM = 0, HOUR = 9, HOUR_OF_DAY = 9, MINUTE = 0, SECOND = 0, MILLISECOND =?, ZONE_OFFSET =?, DST_OFFSET =?]
Why any thoughts are happening?
You're reaching field sustainability instead of getting it 'value. I believe that you want to do something like this,
System.out.println ("DAY_OF_WEEK =" + theDate.get (Calendar. DAY_OF_WEEK));
Comments
Post a Comment