Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18599

Re: Date/Calendar confusion

From "John B. Matthews" <nospam@nospam.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Date/Calendar confusion
Date 2012-09-07 21:02 -0400
Organization The Wasteland
Message-ID <nospam-64D325.21022107092012@news.aioe.org> (permalink)
References <3a69eb4a-f3c0-4b56-9a67-6833ccb2a1c8@googlegroups.com> <nospam-D06BA0.20534806092012@news.aioe.org> <3931f4ca-a41a-489a-8521-545eaed21742@googlegroups.com>

Show all headers | View raw


In article <3931f4ca-a41a-489a-8521-545eaed21742@googlegroups.com>,
 Lew <lewbloch@gmail.com> wrote:

>  John B. Matthews wrote:
> > Ulrich Scholz  wrote:

[Valuable clarifications elided.]

> >     calendar2.set(Calendar.YEAR, 1970);
> >     calendar2.set(Calendar.MONTH, Calendar.JANUARY);
> >     calendar2.set(Calendar.DAY_OF_MONTH, 1);
> > 
> >     calendar2.clear(Calendar.HOUR);
> 
> Better: 'calendar2.set(Calendar.HOUR, 0);'

Can I impose on you to amplify further? Is this related to "the 
resolution rule for the time of day," mentioned in clear(int)?

<http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#time_resolution>
<http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#clear(int)>

> >     calendar2.clear(Calendar.MINUTE);
> >     calendar2.clear(Calendar.SECOND);
> >     calendar2.clear(Calendar.MILLISECOND);
> > 
> >     System.out.println(calendar2.getTimeInMillis()); // 0
> > }

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Date/Calendar confusion Ulrich Scholz <d7@thispla.net> - 2012-09-06 01:03 -0700
  Re: Date/Calendar confusion nogales <nogales.manuel@gmail.com> - 2012-09-06 02:29 -0700
  Re: Date/Calendar confusion Lew <lewbloch@gmail.com> - 2012-09-06 10:21 -0700
  Re: Date/Calendar confusion "John B. Matthews" <nospam@nospam.invalid> - 2012-09-06 20:53 -0400
    Re: Date/Calendar confusion Lew <lewbloch@gmail.com> - 2012-09-07 11:01 -0700
      Re: Date/Calendar confusion "John B. Matthews" <nospam@nospam.invalid> - 2012-09-07 21:02 -0400
        Re: Date/Calendar confusion Lew <lewbloch@gmail.com> - 2012-09-07 18:44 -0700
          Re: Date/Calendar confusion "John B. Matthews" <nospam@nospam.invalid> - 2012-09-08 09:12 -0400
            Re: Date/Calendar confusion Lew <lewbloch@gmail.com> - 2012-09-08 16:51 -0700

csiph-web