Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Timestamp  RSS feed

 
jay lai
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
How do i set the timestamp that I received from the user enter to a specifice time.

for example: user enter 05/23/2006 or May 23, 2006---> need to display later on as 05/23/2006 6:00 AM (need to be @6:00 AM)


I got 05/23/2006 12:00 AM displayed, but how do I specificly set to 6:00 AM??
Please help, and many thanks in advance
[ May 23, 2006: Message edited by: Bear Bibeault ]
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timestamp extends java.util.Date. Hence, you can use a Calendar to adjust the values and store them back in the Timestamp



When it comes to formatting, consider java.text.SimpleDateFormat.

I hope this helps!
 
KiranKumar Gogineni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay Lai,
Could you please explain a bit more clearly about what you are going to accomplish by setting 6:00 AM? I am not able to visualize the purpose.
Regards,
Kiran
 
jay lai
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all: thanks to Edwin and KiranKumar for response.
I am going to try Edwin approach, see if it works

I am trying to re-display the date that user enter in Timestamp format mm/dd/yyyy 6:00 AM. Does not matter what time they enter, if they enter today at 05/24/2006 11:15 pm, it should store into database as 05/24/2006 6:00 AM. Hope this explain a bit clearer.

thanks,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!