title: How can I pass an empty String value to a Date field in Java
body: <p>I have a scenario in a current java program where if the user enters a certain date (01/01/1900) in an excel Date field I'm supposed to flag that and clear the value out in the database.  In this case since the field is a Date type, I need to pass it to an xml as "" i.e and empty String since I can't just pass null.  I'm getting an error because it is expecting a format of "yyyy-MM-dd" to pass to the xml and not "".  Of course when setting the Date field to a certain value, I can't just pass an empty String in the setVesselDate() method because it will complain saying it must be in so so format.  I have a method that validates the date (handleValidateDate) that returns the sql Date value.  </p>
  
  <p>Any recommendation to actually set the date field as "" would be helpful.  Below is the code I have:</p>
  
  <pre><code>if (vesselAssignmentObj.getVesselDate().length() &gt; 0) 
  {
      String clearOutDateFlag = "1900-01-01";
      String clearField = "";
      //below returns a dateformat of yyyy-MM-dd at i
      vesselDate = handleValidateDate(vesselAssignmentObj.getVesselDate(), VESSEL_ASSIGNMENTS_VESSEL, i);
  
      if (vesselDate.toString().equals(clearOutDateFlag))
      {
          vesselAssignmentObj.setVesselDate(String.valueOf(vesselDate.toString().equals(clearField)));
      }
      else
      {
          vesselAssignmentObj.setVesselDate(String.valueOf(vesselDate).toString());
      }
  }
  </code></pre>