Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting Timestamp to date, month, year

 
Joel Carklin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can someone please give me some pointers on the process of converting a java.sql.Timetamp into 3 int primitives, namely extracting date(1-31) month and year. I'm getting confused by all the different classes involved with date/time (ie Date, Timestamp, DateFormat, Calendar, etc)
Thanks
Joel
 
Chad McGowan
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you have the Timestamp object, use:

Chad
 
satish bora
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may like to add 1 to months, as Months start from 0 to 11.
(i.e .cal.get(Calendar.MONTH)+1 )
Cheers,
Satish
 
Joel Carklin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satish and Chad
Works great, just the info I needed
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic