Results 1 to 2 of 2
  1. #1
    tarkowc is offline Member
    Join Date
    Jan 2011
    Posts
    14
    Rep Power
    0

    Default 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.

  2. #2
    tarkowc is offline Member
    Join Date
    Jan 2011
    Posts
    14
    Rep Power
    0

    Default Figured it out.

    It took me all day, but I finally figured it out. Thank you for the help.

Similar Threads

  1. Convert String to Binary
    By erakhman in forum New To Java
    Replies: 1
    Last Post: 09-01-2010, 08:25 AM
  2. convert obj to string
    By isme in forum New To Java
    Replies: 11
    Last Post: 06-14-2010, 10:54 AM
  3. Convert string hh:mm to milliseconds
    By sm123 in forum New To Java
    Replies: 2
    Last Post: 03-11-2010, 12:29 PM
  4. trying to convert an interger to a string
    By matpj in forum New To Java
    Replies: 12
    Last Post: 01-15-2009, 10:08 AM
  5. convert a really big string (len 39) to bigdecimal
    By coolsig in forum Advanced Java
    Replies: 6
    Last Post: 06-14-2008, 02:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •