-->
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.  [ 7 posts ] 
Author Message
 Post subject: how about a 24hour format?
PostPosted: Mon Nov 24, 2003 9:47 pm 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
i use a Date type in my schema like this:

Code:
    /**
    * @hibernate.property not-null="true" update="false"
    */
   public java.util.Date getPostTime()
   {
      return postTime;
   }

   public void setPostTime(java.util.Date aPostTime)
   {
      postTime = aPostTime;
   }


and use hql like this:

Code:
   private static final String selectpostbytime = "from Post as post where post.postTime <= :end and post.postTime >= :begin ;



set the parameters like this:

Code:
   query.setTimestamp("end" , end);
   query.setTimestamp("begin" , begin);


and begin / end is java.util.Date

or like this:

Code:
   query.setCalendar("end" , end);
   query.setCalendar("begin" , begin);


and begin / end is java.util.Calendar

if my computer time now is 10:24am , everything is ok

but if my computer time now is 10:24pm , in my log shows that:

Code:
   binding '24 十一月 2003 10:36:22' to parameter: 1
   binding '01 一月 1970 08:00:00' to parameter: 2


you can see that , my time now shoud be 22:36:22 , but bind data is 10:36:22 , why?

now the only i can do is changeing the code like below , it will work well :

Code:
   sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   query.setString("end" , sdf.format(end));
   query.setString("begin" , sdf.format(begin));


can i just bind java.util.Date to solve this problem???

my system time format is : HH:mm:ss


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 9:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Its just a log message...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 9:59 pm 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
..................

really?

i don't think so

only when the msg like this , my application run perfect.........

Code:
binding '2003-11-24 22:36:22' to parameter: 1
binding '2003-11-24 08:00:00' to parameter: 2


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 10:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
yes, really.

We of course do not use a SimpleDateFormat to bind the Date to JDBC ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 10:10 pm 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
so , what i do is the only way to solve my problem about 24hour???

sigh..............


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 10:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Unless your jdbc driver is completely buggy, you are mistaken. setTimestamp(date) works just fine for a 24hr time. All it does is call

Code:
PreparedStatement.setTimestamp( index, new Timestamp( date.getTime() ) );


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 10:18 pm 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
now i am useing mysql

i will change it to oracle and try it again

thank you , gavin!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.