ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Goodin" <brandon.goo...@gmail.com>
Subject Re: Using non-default timezones
Date Mon, 05 Jun 2006 16:48:59 GMT
iBATIS does not mess with your date values in any way that I am aware
of. What you pass in is what gets stored. If iBATIS is changing your
date values upon insertion then this would be a bug. So, it is your
responsibility to set the Date value on your object correctly prior to
asking iBATIS to insert the information into your database. As stated
by Graeme, you will need to use the Calendar object to accomplish
this.

Brandon Goodin



On 6/5/06, Mayeul MARGUET <mmarguet@aneo.fr> wrote:
> Subject: Using non-default timezones
>
> Hi!
>
> I'm using iBatis to store and fetch dates and hourly timestamps in and
> from an Oracle database.
> An sql-map fragment is given below as example.
>
> I need these dates and timestamps to be stored as their UTC values, but
> when I insert a date using an iBatis insert statement, the value is
> stored using my default timezone (ie: for a GMT-1 default timezone,
> 01/01/2006 00:00:00 UTC is stored as 12/31/2005 or 12/31/2005 23:00:00).
> This is a logical default behaviour, but still not the one I need.
>
>
> I did find a few sql-map examples around the net suggesting there was an
> easy way to handle timezones, but failed both to understand how to use
> them and to find a documentation on the subject of dates and timezones
> with iBatis.
>
>
> Is there an official way to do it, which would save me the hassle of
> modifying my default timezone or storing my dates and timestamps as
> text?
> Could you point me to a documentation covering the subject?
>
> Or do you think I am missing something and should investigate towards
> some Oracle configuration I'm not aware of?
>
> Thanks!
>
>
> Here is my sql-map example, kinda straightforward:
>
>         <resultMap id="NameTimestampDate.map"
> class="NameTimestampDate.class">
>                 <result property="name" column="NAME" />
>                 <result property="timestamp" column="MY_TIMESTAMP" />
>                 <result property="date" column="MY_DATE" />
>         </resultMap>
>
>         <select id="getNameTimestampDateByName"
>                 resultMap="NameTimestampDate.map"
>                 parameterClass="java.lang.String">
>
>                 <![CDATA[
>                 SELECT * FROM TEST_TIMESTAMPS
>                         WHERE NAME = #name#
>                 ]]>
>         </select>
>
>         <insert id="insertNameTimestampDate"
>                 parameterClass="NameTimestampDate.class">
>
>                 <![CDATA[
>                 INSERT INTO TEST_TIMESTAMPS (NAME, MY_TIMESTAMP,
> MY_DATE)
>                         VALUES (#name#, #timestamp#, #date#)
>                 ]]>
>         </insert>
>
> --
> Mayeul
>
>

Mime
View raw message