Results 1 to 2 of 2
Thread: Convert SQL getDate to String.
- 01-28-2011, 03:54 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 14
- Rep Power
- 0
Convert SQL getDate to String.
I am trying to convert a date that I am pulling from a SQL database to a String. Some of the date fields are blank. How can I check to see if the date field is blank before trying to convert it to a string? When I try to convert a date from a result set, that was blank in the database, to a String I get a null value error.
The code I am trying to use is below:
String tempString8 = "";
Date dt = rs.getDate("DateAcquired");
tempString8 = dt.toString();
I also tried the following code, but am still getting a null error:
String tempString8 = "";
Date dt = rs.getDate("DateAcquired");
if(dt.toString().isEmpty()){System.out.println("It is.");}
What am I doing wrong?
Any suggestions on other code I could use?
Thank you very much in advance.
- 01-28-2011, 09:27 PM #2
Member
- Join Date
- Jan 2011
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
Convert String to Binary
By erakhman in forum New To JavaReplies: 1Last Post: 09-01-2010, 08:25 AM -
convert obj to string
By isme in forum New To JavaReplies: 11Last Post: 06-14-2010, 10:54 AM -
Convert string hh:mm to milliseconds
By sm123 in forum New To JavaReplies: 2Last Post: 03-11-2010, 12:29 PM -
trying to convert an interger to a string
By matpj in forum New To JavaReplies: 12Last Post: 01-15-2009, 10:08 AM -
convert a really big string (len 39) to bigdecimal
By coolsig in forum Advanced JavaReplies: 6Last Post: 06-14-2008, 02:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks