| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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. > > |
|
#2
| |||
| |||
| 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. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.