Subject | Re: [Firebird-Java] Inserting only date-part of timestam with Jaybird and Hibernate |
---|---|
Author | Mark Rotteveel |
Post date | 2010-11-16T16:11:55Z |
> Hi,There are a number of ways (in order of 'best' to 'worse'):
>
> I am not 100% sure this is related to Firebird/Jaybird, so forgive me in
> case I'm wrong.
>
> I am inserting a row with hibernate, and for setting a date column
> (Timestamp in sql) to today I use:
>
> record.setCreationDate( new java.util.Date() );
>
> This works generally, but includes the time-part (16.11.2010 15:27:24),
> whereas I would only want the date (16.11.2010)
>
> Does anyone know how to fix this?
1) Use DATE as your column type if you are not interested in the time portion, not TIMESTAMP; TIMESTAMP is simply the wrong type for this
2) Set the time portions to zero
3) Use java.sql.Date, not java.util.Date (java.sql.Date does not store time portion)
4) Add a trigger to normalize the TIMESTAMP value by cutting off time information (eg by casting to DATE)
Mark
--
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail