This discussion is archived
6 Replies Latest reply: Mar 26, 2009 7:39 AM by 807588 RSS

about get(Calendar.DAY_OF_WEEK)

807588 Newbie
Currently Being Moderated
Hi,

I would like to ask if GregorianCalendar.get(Calendar.DAY_OF_WEEK) returns 0 for Sunday always, or it depends on the timezone and localization?

Thanks.
  • 1. Re: about get(Calendar.DAY_OF_WEEK)
    thomas.behr Newbie
    Currently Being Moderated
  • 2. Re: about get(Calendar.DAY_OF_WEEK)
    807588 Newbie
    Currently Being Moderated
    first of all Sunday does not return a '0' but a '1'. Sorry about the typo.

    secondly, I just wanted to be sure that get(Calendar.DAY_OF_WEEK) is absolute and does not depend on the localization. This is not mentioned in the reference, so I guess the answer is 'yes'. I thought maybe it was implied somewhere else I might have accidentally missed.

    thirdly, I always refer to the manual before I come here. By RTFM-ing people you are not helping them. Some people (including me) do not know very good English (is this a crime?) so the manual can be ambiguous for them at some parts.
  • 3. Re: about get(Calendar.DAY_OF_WEEK)
    807588 Newbie
    Currently Being Moderated
    xpanta wrote:
    Hi,

    I would like to ask if GregorianCalendar.get(Calendar.DAY_OF_WEEK) returns 0 for Sunday always, or it depends on the timezone and localization?

    Thanks.
    In general you shouldn't depend on the values of those constants, you should be using the constants.
  • 4. Re: about get(Calendar.DAY_OF_WEEK)
    thomas.behr Newbie
    Currently Being Moderated
    xpanta wrote:
    By RTFM-ing people you are not helping them.
    Obviously, I beg to differ.

    xpanta wrote:
    Some people (including me) do not know very good English (is this a crime?) so the manual can be ambiguous for them at some parts.
    No, it's not a crime if your English is not very good. However, "This field takes values SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY." is a very simple sentence, I fail to see how it can be ambiguous (even for someone whose English is weak).

    Much more important is the fact that the documentation does not mention any numeric values but constants (which in turn implies that these values do not change). So, follow tsith's advice and code against the constants.
  • 5. Re: about get(Calendar.DAY_OF_WEEK)
    807588 Newbie
    Currently Being Moderated
    thomas.behr wrote:
    xpanta wrote:
    By RTFM-ing people you are not helping them.
    Obviously, I beg to differ.
    sorry to hear that, because it seems that your 2nd answer and tsith's answer gave me more information than the word "RTFM".


    Much more important is the fact that the documentation does not mention any numeric values but constants >(which in turn implies that these values do not change). So, follow tsith's advice and code against the constants.
    thank you and tsith. This is something I didn't know, although I use it many times (just seems logical to do so)
  • 6. Re: about get(Calendar.DAY_OF_WEEK)
    807588 Newbie
    Currently Being Moderated
    xpanta wrote:
    thomas.behr wrote:
    xpanta wrote:
    By RTFM-ing people you are not helping them.
    Obviously, I beg to differ.
    sorry to hear that, because it seems that your 2nd answer and tsith's answer gave me more information than the word "RTFM".
    But that word is a link to the API where it says what values that field can take.
    >
    >
    Much more important is the fact that the documentation does not mention any numeric values but constants >(which in turn implies that these values do not change). So, follow tsith's advice and code against the constants.
    thank you and tsith. This is something I didn't know, although I use it many times (just seems logical to do so)
    In general don't depend on anything that isn't documented in the API - the API documentation is a contract of sorts, but undocumented features might be changed or removed without warning.

    Good Luck

    Lee