I have a question that I'm hoping there is an easy answer to..... I don't want the solution to be too messy, ie string manipulation if i can help it.
I am querying the user to enter a date, in the format dd-mmm-yyyy, in other words 12-Dec-2004(This is a UK application), however in order for me to convert the date to a timestamp for use with SQL Server, it must be in the format yyyy-mm-dd. Is there an existing class that handles conversions of this sort or am i looking at writing a method to do it? Thanks alot
It strikes me that you may be going the wrong way about this. If you're using JDBC to run a query on the database, it would be safer to use a PreparedStatement, and then use the setTimestamp() method to set parameters in your SQL. This takes care of all the necessary conversions behind the scenes. Generating SQL strings directly should generally be avoided, if possible, because if you're not careful it can leave you open to SQL insertion attacks. David Peterson
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad: