-->
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 format in mapping file
PostPosted: Mon Sep 13, 2004 3:59 pm 
Newbie

Joined: Thu Jul 08, 2004 6:07 pm
Posts: 4
Hello,

Is there a way to specify date/time format in the mapping file
for property value conversion between java.lang.String and Sybase datetime?

Thanks a lot.


Top
 Profile  
 
 Post subject: Re: date/time format in mapping file
PostPosted: Tue Sep 14, 2004 5:59 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
dimavin wrote:
Is there a way to specify date/time format in the mapping file
for property value conversion between java.lang.String and Sybase datetime?


Not as far as I know but you can do it yourself in your java class.

Code:
public class MyClass {
   private String dateString;

   public Date getDate() {
      return dateParser.parse(dateString);
   }

   public void setDate(Date aDate) {
      this.dateString = dateParser.format(aDate);
   }

   ...
}


In your Hibernate mapping file, persist the 'date' property and not the dateString...

Code:
<class MyClass>
   ...
   <property name="date" />
   ...
</class>



Note: why do you keep in your dates in String format - you should convert them as soon as possible in java.util.Date...
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2004 6:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If you can't rework your classes, a UserType would be an option, too - I would also recommend changing to java.util.Date though.


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.