| Author |
converting the date/time fields into Strings
|
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
Hello, I have a field of date/time as a part of my sql statement to update the database. I want to convert that field into String and then, use that string in my SQL. This is wut im doing: String m = (new SimpleDateFormat("EEE' 'yyyy-MM-dd' 'HH:mm:ss")).format((java.util.Date) start, new StringBuffer(), new FieldPosition(DateFormat.YEAR_FIELD)).toString(); Is this a right way of converting???..any suggestions or help would be greatly appreciated.
|
 |
Andy Bowes
Ranch Hand
Joined: Jan 14, 2003
Posts: 171
|
|
It is difficult to know whether what you are trying to do is correct without seeing the SQL statement. I'd prefer to use a PreparedStatement rather than do all the datetime formatting that you are doing as I feel it is more readable. i.e. HTH
|
Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
|
 |
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
hello, my sql statement looks like this: update = "UPDATE vippass SET start = \"" + m + "\", email=\"" + email + "\" WHERE passcode=\"" + passcode + "\"";
|
 |
Andy Bowes
Ranch Hand
Joined: Jan 14, 2003
Posts: 171
|
|
Hi Sam, In that case I would rewrite your UPDATE statement as: HTH
|
 |
 |
|
|
subject: converting the date/time fields into Strings
|
|
|