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.