This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to convert Timestampformat to another format

 
kiranb reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have a requirement to format the Timestamp format to another format, could any one explain the steps to do it.

The default timestamp format is yyyy-MM-dd HH:MM:SS

I need to fomrat it to dd-MM-yyyy HH:MM:SS

Please help to do this, and the return type must be always java.sql.TimeStamp.


Thanks in Advance.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.sql.TimeStamp does not hold any particular format. It just holds the date itself (the values).
If you want to format dates, you can have a look at java.text.SimpleDateFormat.
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe is correct. The only way to get hold of a date in a particular format is to use a String for the format.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic