You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Larry Meadors <lm...@apache.org> on 2006/10/11 19:25:27 UTC

Re: Date format conversion to/from db

Make your beans use java.util.Date.

Use <fmt:*> jsp tags for output.

In your forms, pick a date format, then on the backend, do the
conversion from string to date - spring does most of that for you,
IIRC.

Larry


On 10/11/06, Ou, Stan (Mission Systems) <ST...@ngc.com> wrote:
>
>
>
> Hi all,
>
> I've an application that integrates Spring and iBatis with an Oracle
> backend.  We were using Oracle's bc4j before we made the switch.  Since our
> dates are persisted to the db in a different format from what we display on
> the jsp, what would be the best approach to do the conversion?  The most
> straightforward way I think is use a util class to do the conversion in the
> getter/setter of the pojo but I'll have to make the pojo's setter smart
> enough to know whether I'm reading from the db or being bound to a form by
> Spring, something along this line:
>
> If reading from db for display on jsp
>   convert from db to gui format
>
> If being bound to Spring form and then persisted to db
>   convert from gui to db format
>
> The same goes for the getter.
>
> Our pojos are auto generated, so any logic added will get wiped out if
> someone regenerates the pojo.
> Can anyone shed some lights on this?  Any suggestions are welcomed. Thanks.
>
> Stan

Re: Date format conversion to/from db

Posted by Larry Meadors <lm...@apache.org>.
Hmm, it's been years since I used the display: tags, but I think you
could use a decorator for that case - look in the docs for the
display: tags for examples.

Larry

On 10/11/06, Ou, Stan (Mission Systems) <ST...@ngc.com> wrote:
> Thanks for your quick reply, Larry.
>
> In the jsp, we also use displaytag to display if it's a listing, so not
> sure if the <fmt:> tag could fit in, but will give it a try.  The
> displaytag syntax is as follow:
>
> <display:table id="aList" name="aList" pagesize="25"
> requestURI="/shr.gcss">
>         <display:column property="someDate" title="Some Date" />
>
>
> -----Original Message-----
> From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf
> Of Larry Meadors
> Sent: Wednesday, October 11, 2006 10:25 AM
> To: user-java@ibatis.apache.org
> Subject: Re: Date format conversion to/from db
>
> Make your beans use java.util.Date.
>
> Use <fmt:*> jsp tags for output.
>
> In your forms, pick a date format, then on the backend, do the
> conversion from string to date - spring does most of that for you, IIRC.
>
> Larry
>
>
> On 10/11/06, Ou, Stan (Mission Systems) <ST...@ngc.com> wrote:
> >
> >
> >
> > Hi all,
> >
> > I've an application that integrates Spring and iBatis with an Oracle
> > backend.  We were using Oracle's bc4j before we made the switch.
> > Since our dates are persisted to the db in a different format from
> > what we display on the jsp, what would be the best approach to do the
> > conversion?  The most straightforward way I think is use a util class
> > to do the conversion in the getter/setter of the pojo but I'll have to
>
> > make the pojo's setter smart enough to know whether I'm reading from
> > the db or being bound to a form by Spring, something along this line:
> >
> > If reading from db for display on jsp
> >   convert from db to gui format
> >
> > If being bound to Spring form and then persisted to db
> >   convert from gui to db format
> >
> > The same goes for the getter.
> >
> > Our pojos are auto generated, so any logic added will get wiped out if
>
> > someone regenerates the pojo.
> > Can anyone shed some lights on this?  Any suggestions are welcomed.
> Thanks.
> >
> > Stan
>

RE: Date format conversion to/from db

Posted by "Ou, Stan (Mission Systems)" <ST...@ngc.com>.
Thanks for your quick reply, Larry.

In the jsp, we also use displaytag to display if it's a listing, so not
sure if the <fmt:> tag could fit in, but will give it a try.  The
displaytag syntax is as follow:

<display:table id="aList" name="aList" pagesize="25"
requestURI="/shr.gcss">
	<display:column property="someDate" title="Some Date" />


-----Original Message-----
From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf
Of Larry Meadors
Sent: Wednesday, October 11, 2006 10:25 AM
To: user-java@ibatis.apache.org
Subject: Re: Date format conversion to/from db

Make your beans use java.util.Date.

Use <fmt:*> jsp tags for output.

In your forms, pick a date format, then on the backend, do the
conversion from string to date - spring does most of that for you, IIRC.

Larry


On 10/11/06, Ou, Stan (Mission Systems) <ST...@ngc.com> wrote:
>
>
>
> Hi all,
>
> I've an application that integrates Spring and iBatis with an Oracle 
> backend.  We were using Oracle's bc4j before we made the switch.  
> Since our dates are persisted to the db in a different format from 
> what we display on the jsp, what would be the best approach to do the 
> conversion?  The most straightforward way I think is use a util class 
> to do the conversion in the getter/setter of the pojo but I'll have to

> make the pojo's setter smart enough to know whether I'm reading from 
> the db or being bound to a form by Spring, something along this line:
>
> If reading from db for display on jsp
>   convert from db to gui format
>
> If being bound to Spring form and then persisted to db
>   convert from gui to db format
>
> The same goes for the getter.
>
> Our pojos are auto generated, so any logic added will get wiped out if

> someone regenerates the pojo.
> Can anyone shed some lights on this?  Any suggestions are welcomed.
Thanks.
>
> Stan