This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Formatting

 
niranjan angadi
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am getting Date column (DueDate) from database through hibernate. It will be of format "6/23/2005 12:02:30 PM". I need to format it to "yyyy-MM-dd" before displaying/setting it to DO object (as a date only).

I used SimpleDateFormat class to format date. But sdf.format(dueDate) returns string, i need date object back so as to set it to DO object. So i used sdf.parse(sdf.format(dueDate)) which returns date object, but now returned date will be not in my required format("yyyy-MM-dd"), it will be in "Tue Jun 12 00:00:00 IST 2007".

Could you help me out how to format the date in required format and get back as date object.

Or else, simply I have Date Time object and i want to truncate time part. Want to display only date (yyyy-MM-dd, 2007-06-12).
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use two instances of SimpleDateFormat. One to parse, one to format.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic