You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Gary Jarrel <ga...@gmail.com> on 2007/09/13 07:09:58 UTC

Cayenne and GMT Date and Time

Hi All!

I'm working on a Cayenne app, and am looking for a way to store all
dates in the database in GMT irrespective of which locate the
application/server is running in?

I noticed that even when I would use the code like:

TimeZone tzGmt = getGmtTimeZone();
Calendar cal = new GregorianCalendar();
cal.get(Calendar.HOUR); //this line might not be important at all
cal.setTimeZone(TimeZone.getTimeZone("GMT");

Then use the date object of cal.getTime() it still stores the date in
the locate which the server running the application is configured for!

Has anyone done anything similar?

Thank you!

Gary

Re: Cayenne and GMT Date and Time

Posted by Michael Gentry <bl...@gmail.com>.
Hi Gary,

I'll start off with saying I haven't done any real date processing
with Cayenne (outside of calling setModifiedDate() on some records
with the current date/time).  However, I know from working with EOF
and some databases that the timezone was NOT stored in the database.
For example, with Sybase, the date/time was all relative (server
locale).  If Sybase had 13:00 for the time, we'd read that as 13:00
EST (or EDT, you get the idea) and there'd be no +0500 (or +0600)
associated with it.  The summation of my ramble is it might not be
Cayenne's fault.  :-)  You might need cover methods on your date
methods to do conversions for you.  I'm just guessing, though.

/dev/mrg


On 9/13/07, Gary Jarrel <ga...@gmail.com> wrote:
> Hi All!
>
> I'm working on a Cayenne app, and am looking for a way to store all
> dates in the database in GMT irrespective of which locate the
> application/server is running in?
>
> I noticed that even when I would use the code like:
>
> TimeZone tzGmt = getGmtTimeZone();
> Calendar cal = new GregorianCalendar();
> cal.get(Calendar.HOUR); //this line might not be important at all
> cal.setTimeZone(TimeZone.getTimeZone("GMT");
>
> Then use the date object of cal.getTime() it still stores the date in
> the locate which the server running the application is configured for!
>
> Has anyone done anything similar?
>
> Thank you!
>
> Gary
>