aspose file tools*
The moose likes JSP and the fly likes hours and minutes set/get sql timestamp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "hours and minutes set/get sql timestamp" Watch "hours and minutes set/get sql timestamp" New topic
Author

hours and minutes set/get sql timestamp

Lou Caudell
Ranch Hand

Joined: Oct 06, 2001
Posts: 32
I am in need of providing a page to permit the manipulation of hours and minutes in a sql timestamp. The user will be able to set the hour and minute for an event. Of course I could parse out string values, but I want the correct class structure, so that a call to get/set the hour and minute values are possible. Anyone have thoughts on the class structure to use here.
<class type> <instName> = rs.getTimestamp(1);
Lou Caudell
Ranch Hand

Joined: Oct 06, 2001
Posts: 32
I should add, taglibs are not an option at this time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Not something you should really be doing in a JSP. Pass the user input, which will be strings (no way aorund that) to a class that employs java.util.Calendar to set and get the individual field values.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lou Caudell
Ranch Hand

Joined: Oct 06, 2001
Posts: 32
Actually, I do have an mvc2 architecture. So if I understand your suggestion, the calendar class should be instantiated from the timestamp value?. Can you give an example?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

I can't really, since I'm not understanding exactly what you are doing. But, if you want to set and get particular fields from a date value, Calendar allows you to do that. When setting the timestamp into the Calendar you are likely to lose the nano values so if that level of precision is important to you, it may not be viable.
Lou Caudell
Ranch Hand

Joined: Oct 06, 2001
Posts: 32
I have worked out the reading of the timestamp with a timeDate class that instantiates calendar. But I am still struggling with how to set the new hour, minute values back into a timestamp since timestamp( yy:mm:dd hh:mm:ss.sss ) has been deprecated.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Use the constructor that takes a long as the argument:

new java.sql.Timestamp(calendar.getTime().getTime())


Question - What are you trying to specify? an exact moment in time or a time of day to occur every day?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hours and minutes set/get sql timestamp
 
Similar Threads
Calculating download time
classes and methods
getting a clock to update correctly
Constructor
Please help me this. Im new to this.