This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi; I have a jsp and passing start_date as a string with this format input string 2006-01-02 03:04:00 database timestamp: 2006-01-02 03:04:00
in the database, the java method expected Date '2006-01-02 03:04:00' as parameter . In the SQL it search like "select * from table where date1 >= '2006-01-01 12:13:00' and date2 <= '2007-01-02 12:13:00'"
Here what I do:
Many thanks for your help. Regards
Carol Enderlin
drifter
Ranch Hand
Joined: Oct 10, 2000
Posts: 1348
posted
0
Your input string does not have the am/pm marker (aa) that your date format has.
jay lai
Ranch Hand
Joined: Apr 04, 2002
Posts: 180
posted
0
Thanks Carol: i fixed it, but for example on my jsp i enter 2007-01-02 15:00:00 i ran through my code [see previous post], the output string is <b>Tue Jan 02 15:00:00 </b> not the format <b> "yyyy-MM-dd hh:mm:ss" </b> as I wanted? Any ideas how to fix this
jay lai
Ranch Hand
Joined: Apr 04, 2002
Posts: 180
posted
0
Can someone please help, this is what I have so far, input date from jsp: 2007-02-03 09:00:00 as a string I need to convert this to a java.util.Date format yyyy-MM-dd hh:mm:ss
Greatly appreciated if you can help thanks much
Carol Enderlin
drifter
Ranch Hand
Joined: Oct 10, 2000
Posts: 1348
posted
0
Sorry, but I'm not following your problem.
You've got a String representing a date. (inputstring) You turn it into a Date. (d1) You turn it back into the String you started with. (mydt) Now you cannot turn it back into a date? (what is wrong with d1?)
jay lai
Ranch Hand
Joined: Apr 04, 2002
Posts: 180
posted
0
Carol: sorry for the confusing: Let me try again:
On the jsp: there are two seperate field: Date, and Hour, User can enter date with format yyyy-MM-dd and Hour hh:mm:ss
When I got this two fields, i need to somehow reformat to be the whole thing yyyy-MM-dd hh:mm:ss,
I try to concate the string, but it won't work
So from the above code , you are saying that I just using d1 to passing into the method that epxect Date private String getSomething (Date myDate) // passing d1 in here, but I got stuck at the hour,minute,seconde.
any ideas or hints. Greatly appreciated THNkS
Carol Enderlin
drifter
Ranch Hand
Joined: Oct 10, 2000
Posts: 1348
posted
0
Try printing out your intermediate strings or use a debugger to look at what you are doing.
It looks like you are missing the space between date and time components when you concatenate.
Aditya Kumar
Ranch Hand
Joined: Oct 31, 2006
Posts: 46
posted
0
Instead of modifying the Java code why dont you use the to_date/to_char functions in SQL? Its much simpler that way.
Originally posted by Aditya Kumar: Instead of modifying the Java code why dont you use the to_date/to_char functions in SQL? Its much simpler that way.
...unless of course you change databases to one that does not support these functions (since they are not standard SQL).