-->
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: How to use the “month first” format in a date/timestamp
PostPosted: Mon Dec 26, 2005 12:00 am 
Newbie

Joined: Sun Dec 25, 2005 11:34 pm
Posts: 1
The Tutorial has the example for mapping Java date to the database column using timestamp type. A string received from HTML is converted to dd//mm/yyyy.

Is it possible to specify the conversion format as /mm/dd/yyyy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 12:56 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

This is noway a problem of hibernate.

Ok, Anyway this will work for you

Your date is

java.util.Date date = "12/12/2005" // format "dd/MM/yyyy"

Use the below Class to convert the format which you want

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

sdf.parse(date); // will give you the format in which you need.

You can format to whatever format you need

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 10:23 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
Agree with above poster. More detailed answer is that the DB and Java represent dates numerically (number of milliseconds since Jan 1, 1900 or some such). They are input from the user as strings, and parsed into this internal numeric format, then they are rendered on the GUI as strings again, using the SimpleDateFormat.


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.