Re: Hibernate Date formating

This is a discussion on Re: Hibernate Date formating within the JDBC JAVA forums in Framework and Interface Programming category; To change date format in oracle you can execute the following query before executing your original query: statement.execute("alter session set nls_date_format='MM/DD/YYYY HH24:MI:SS'"); this will change the date format for the current connection. To construct the full date object from database you should use the code similar to the following instead of using resultset.getDate(..) which only returns the date part of the original date. java.util.Date myDate = new java.util.Date(myResultSet.getTimestamp("myDate"). getTime()); I hope this will help. -Yasir "Lionel" <SPAMcoollATfreePOINTfr> wrote in message news:41613cb9$0$18031$636a15ce @ news.free.fr... > Hi !! > > I would like to compare for equality a given date (which is ...

Go Back   Application Development Forum > Framework and Interface Programming > JDBC JAVA

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 11-02-2004, 12:18 AM
Yasir Khan
Guest
 
Default Re: Hibernate Date formating

To change date format in oracle you can execute the following query before
executing your original query:

statement.execute("alter session set nls_date_format='MM/DD/YYYY
HH24:MI:SS'");

this will change the date format for the current connection.

To construct the full date object from database you should use the code
similar to the following instead of using resultset.getDate(..) which only
returns the date part of the original date.

java.util.Date myDate = new
java.util.Date(myResultSet.getTimestamp("myDate"). getTime());

I hope this will help.

-Yasir

"Lionel" <SPAMcoollATfreePOINTfr> wrote in message
news:41613cb9$0$18031$636a15ce@news.free.fr...
> Hi !!
>
> I would like to compare for equality a given date (which is a formated
> string 'dd/mm/yyyy') to my database's value which has been set using
> sysdate (oracle).
> I mean, how can I format my sysdate as to_char(sysdate, 'dd/mm/yyyy')

would
> do ?
>
> Explanation:
> If I use dateFormat.parse(String) to transform my String to a

java.util.Date
> myDate, I get: Mon Oct 04 00:00:00.
> But sysdate has hours/minutes/seconds, and the equals test with myDate

from
> oracle always fail if I don't truncate sysdate.
>
> Actually I use a Expression.sql(String) to truncated the sysdate with
> oracle's to_chat but i find this solution kludgy.
> I can't find any equivalent in Hibernate.
> Thanks.
>
>



Reply With Quote
  #2  
Old 11-02-2004, 01:24 AM
Lionel
Guest
 
Default Re: Hibernate Date formating

Yasir Khan wrote:
> To change date format in oracle you can execute the following query
> before executing your original query:
>
> statement.execute("alter session set nls_date_format='MM/DD/YYYY
> HH24:MI:SS'");
>
> this will change the date format for the current connection.


I don't want to change the date format.
I just want to compare two dates for equality in a HQL request.

> I hope this will help.


No but thanks anyway.


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:24 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.