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


Groups > comp.lang.java.programmer > #5660 > unrolled thread

Converting a Date Object to a GregorianCalendar Object

Started byKevinSimonson <kvnsmnsn@hotmail.com>
First post2011-06-24 16:54 -0700
Last post2011-06-27 19:38 -0400
Articles 7 — 5 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Converting a Date Object to a GregorianCalendar Object KevinSimonson <kvnsmnsn@hotmail.com> - 2011-06-24 16:54 -0700
    Re: Converting a Date Object to a GregorianCalendar Object Jeff Higgins <jeff@invalid.invalid> - 2011-06-24 20:43 -0400
      Re: Converting a Date Object to a GregorianCalendar Object KevinSimonson <kvnsmnsn@hotmail.com> - 2011-06-25 14:29 -0700
        Re: Converting a Date Object to a GregorianCalendar Object Lew <noone@lewscanon.com> - 2011-06-26 14:06 -0400
    Re: Converting a Date Object to a GregorianCalendar Object Roedy Green <see_website@mindprod.com.invalid> - 2011-06-24 18:35 -0700
      Re: Converting a Date Object to a GregorianCalendar Object Dr J R Stockton <reply1126@merlyn.demon.co.uk> - 2011-06-27 21:36 +0100
        Re: Converting a Date Object to a GregorianCalendar Object Lew <noone@lewscanon.com> - 2011-06-27 19:38 -0400

#5660 — Converting a Date Object to a GregorianCalendar Object

FromKevinSimonson <kvnsmnsn@hotmail.com>
Date2011-06-24 16:54 -0700
SubjectConverting a Date Object to a GregorianCalendar Object
Message-ID<c6a540ee-ff95-44b7-ab7e-61428d961a15@r33g2000prh.googlegroups.com>
I can go from a GregorianCalendar object to a Date object with the
method getTime().  Is there any way to go from a Date object to a
GregorianCalendar object?  I haven't been able to find a way to do
it.  If there isn't any way to do it, why isn't there any way to do
it?

This is kind of frustrating.  I'm testing some code that stores times
in Date objects.  I can set those objects to certain dates with
setYear(), setMonth(), and setDate(), but those methods are all
deprecated, and so I thought it would be better programming to create
a GregorianCalendar object and convert it to a Date.

But then to check that the Date value is actually getting set right, I
need to convert it back to a GregorianCalendar object, and I don't see
any way to do that.  I could use the Date methods getYear(),
getMonth(), and getDate(), and bypass GregorianCalendar, but once
again all three of those methods are deprecated.  There doesn't appear
to be a way to check these Date objects without using deprecated
methods!  Anybody have any thoughts on this?

Kevin Simonson

[toc] | [next] | [standalone]


#5661

FromJeff Higgins <jeff@invalid.invalid>
Date2011-06-24 20:43 -0400
Message-ID<iu3ami$fab$1@dont-email.me>
In reply to#5660
On 06/24/2011 07:54 PM, KevinSimonson wrote:
> I can go from a GregorianCalendar object to a Date object with the
> method getTime().  Is there any way to go from a Date object to a
> GregorianCalendar object?

Calender.setTime(Date date)?

[toc] | [prev] | [next] | [standalone]


#5672

FromKevinSimonson <kvnsmnsn@hotmail.com>
Date2011-06-25 14:29 -0700
Message-ID<f68ad9a6-f586-4121-bb2f-bc22943c0dc8@q14g2000prh.googlegroups.com>
In reply to#5661
On Jun 24, 6:43 pm, Jeff Higgins <j...@invalid.invalid> wrote:
> On 06/24/2011 07:54 PM, KevinSimonson wrote:
>
> > I can go from a GregorianCalendar object to a Date object with the
> > method getTime().  Is there any way to go from a Date object to a
> > GregorianCalendar object?
>
> Calender.setTime(Date date)?

Thanks!  This worked just fine!

Kevin Simonson

[toc] | [prev] | [next] | [standalone]


#5683

FromLew <noone@lewscanon.com>
Date2011-06-26 14:06 -0400
Message-ID<iu7sej$ka8$3@news.albasani.net>
In reply to#5672
On 06/25/2011 05:29 PM, KevinSimonson wrote:
> On Jun 24, 6:43 pm, Jeff Higgins<j...@invalid.invalid>  wrote:
>> On 06/24/2011 07:54 PM, KevinSimonson wrote:
>>
>>> I can go from a GregorianCalendar object to a Date object with the
>>> method getTime().  Is there any way to go from a Date object to a
>>> GregorianCalendar object?
>>
>> Calender.setTime(Date date)?
>
> Thanks!  This worked just fine!

Learn to use the API docs.
<http://download.oracle.com/javase/6/docs/api/java/util/Calendar.html>

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#5662

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-06-24 18:35 -0700
Message-ID<area0711fsrrpi4a93sfl87gjj8l6ebksr@4ax.com>
In reply to#5660
On Fri, 24 Jun 2011 16:54:32 -0700 (PDT), KevinSimonson
<kvnsmnsn@hotmail.com> wrote, quoted or indirectly quoted someone who
said :

>I can go from a GregorianCalendar object to a Date object with the
>method getTime().  Is there any way to go from a Date object to a
>GregorianCalendar object?  I haven't been able to find a way to do
>it.  If there isn't any way to do it, why isn't there any way to do
>it?

see http://mindprod.com/jgloss/calendar.html
for various recipes.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
One of the great annoyances in programming derives from the irregularity
of English spelling especially when you have international teams.  
I want to find a method or variable, but I don't know precisely
how its is spelled or worded. English is only approximately phonetic.  
Letters are randomly doubled.  The dictionary often lists variant spellings.
British, Canadian and American spellings differ.I would like to see an 
experiment where variable names were spelled in a simplified English, where 
there were no double letters.I also think you could add a number of rules 
about composing variable names so that a variable name for something would
be highly predictable. You would also need automated enforcement of the 
rules as well as possible.

[toc] | [prev] | [next] | [standalone]


#5715

FromDr J R Stockton <reply1126@merlyn.demon.co.uk>
Date2011-06-27 21:36 +0100
Message-ID<94ImRkEanOCOFwW6@invalid.uk.co.demon.merlyn.invalid>
In reply to#5662
In comp.lang.java.programmer message <area0711fsrrpi4a93sfl87gjj8l6ebksr
@4ax.com>, Fri, 24 Jun 2011 18:35:57, Roedy Green <see_website@mindprod.
com.invalid> posted:

> --
> ...
>I would like to see an
>experiment where variable names were spelled in a simplified English, where
>there were no double letters.

Personally, I think that variable names, if semantically significant,
*should* be spelt wrongly, since in that case a global search can
discriminate between  variable names and words of ordinary text.

For that, it helps to be writing pages in Foreign, since programing
words are commonly in English.

-- 
 (c) John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v6.05   MIME.
   Web  <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
  That reminds me.  Are there are any Quebecois astronomers here with
   an interest in orbital dynamics?

[toc] | [prev] | [next] | [standalone]


#5716

FromLew <noone@lewscanon.com>
Date2011-06-27 19:38 -0400
Message-ID<iub49o$v8a$1@news.albasani.net>
In reply to#5715
Roedy Green posted:
>> ...
>> I would like to see an
>> experiment where variable names were spelled in a simplified English, where
>> there were no double letters.


"Simplified spelling brought about sun-spots, the San Francisco earthquake, 
and the recent business depression, which we would never have had if spelling 
had been left all alone."

-- Mark Twain
http://en.wikisource.org/wiki/The_Alphabet_and_Simplified_Spelling

-- 
Lew
<http://triptronix.net/ishbadiddle/archives/2009/07/22/18.19.15/>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web