-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Date/Time problem...
PostPosted: Mon Aug 20, 2007 10:21 am 
Newbie

Joined: Tue Mar 07, 2006 4:56 am
Posts: 17
Hi all,

we currently use nHibernate 1.0.4 on a MS-SQL 2005 database and .Net 2.0. When I do a query against this databse using a date-time value, I get unexpected results.

The first thing is, that I do use named parameters for these queries, so I thought, that there should be no issue. However, we have a strongly internationalized application, which does change the selected locale for the app (e.g. de-DE or even customized ones like en-DE).

It seems, that the date format used by hybernate is incorrect, as it tries to use mm.dd.yyyy instead of dd.mm.yyyy. I could not quite identify the issue, because when I debug nHibernate and look at the produced query, it looks correct (e.g. dd.mm.yyyy), but I still get the wrong result. Only if I use the format yyyy-mm-dd it works correctly in the SQL Query analyzer.

Is there a way to force nHibernate to produce queries which use the international format of yyyy-mm-dd instead of the local setting?

Kind regards, Marco...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 21, 2007 6:02 am 
Newbie

Joined: Mon Jun 18, 2007 2:29 am
Posts: 16
First get the date in the format that hibernate produces. Store it to some variable and format it in the form that you want .

Eg:-
import java.text.*;

String orddat="";

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
try{
orddat = sdf.format(vog.getVororddat()); //database value
}
catch(Exception e){
System.out.println("Error while trying to display date"+e);
}

regards,
Prasanth


Top
 Profile  
 
 Post subject: s
PostPosted: Tue Aug 21, 2007 6:03 am 
Newbie

Joined: Mon Jun 18, 2007 2:29 am
Posts: 16
ss


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.