dateCreated and legal time.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

dateCreated and legal time.

Mauro
In a domain class I've add "Date dateCreated" to have the created date
of a record.
It puts the date but it doesn't observe legal time.
In Italy we are one hour ahead respect the normal time.
There is a way to observe legal time automatically?

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: dateCreated and legal time.

Stefan Armbruster-2
Check your timezone settings on the machine you're running on.
You might use the Java system property 'user.timezone' to fix this.

try:
groovy -Duser.timezone=CEST 'println new Date()'

If this returns the correct time, add '-Duser.timezone=CEST' the grails
command.

Regards,
Stefan
Mauro schrieb:

> In a domain class I've add "Date dateCreated" to have the created date
> of a record.
> It puts the date but it doesn't observe legal time.
> In Italy we are one hour ahead respect the normal time.
> There is a way to observe legal time automatically?
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: dateCreated and legal time.

Robert Fletcher
In reply to this post by Mauro
What's probably happening (assuming that the time zone is set
correctly on your server) is that the Date gets persisted to the
database but the database ignores the time zone information so when
the value is read back it is assumed to be in UTC. There are a couple
of solutions to this:  1) use a database such as PostgreSQL that can
store time zone information in its datetime type, 2) use a Joda Time
DateTime object instead of a Date and persist it as a
PersistentDateTimeTZ (see docs for Joda-Time plugin) which uses 2
columns (be careful as this can cause difficulties with queries).

On Mon, Aug 31, 2009 at 8:43 AM, Mauro<[hidden email]> wrote:

> In a domain class I've add "Date dateCreated" to have the created date
> of a record.
> It puts the date but it doesn't observe legal time.
> In Italy we are one hour ahead respect the normal time.
> There is a way to observe legal time automatically?
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: dateCreated and legal time.

Mauro
2009/8/31 Robert Fletcher <[hidden email]>:
> What's probably happening (assuming that the time zone is set
> correctly on your server) is that the Date gets persisted to the
> database but the database ignores the time zone information so when
> the value is read back it is assumed to be in UTC. There are a couple
> of solutions to this:  1) use a database such as PostgreSQL that can
> store time zone information in its datetime type,

The timezone in my server is correct.
I'm using postgres.
My timezone is Europe/Rome, the time stored in the database is 2 hours back.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: dateCreated and legal time.

Mauro
In reply to this post by Stefan Armbruster-2
2009/8/31 Stefan Armbruster <[hidden email]>:
> Check your timezone settings on the machine you're running on.
> You might use the Java system property 'user.timezone' to fix this.
>
> try:
> groovy -Duser.timezone=CEST 'println new Date()'
>
> If this returns the correct time, add '-Duser.timezone=CEST' the grails
> command.

It returns the time 1 hour back.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email