StringBuffer outStr = new StringBuffer(); String defaultDateStr;   if (defaultDateValue == null) { defaultDateStr = DATE_SAMPLE; } else { SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT); defaultDateStr = formatter.format(defaultDateValue); }  String radioButtonGroupName = nameRoot + HASDATE_SUFFIX;  outStr.append("<td>" + title + "</td>\n"); outStr.append("<td>\n");  outStr.append(displayErrorMessage(request, nameRoot));  outStr.append("  <p>\n"); outStr.append("    <input\n"); outStr.append("      name=\"" + radioButtonGroupName + "\"\n"); outStr.append("      type=\"radio\"\n"); outStr.append("      value=\"" + NODATE_VALUE + "\"\n"); outStr.append(       (defaultDateValue == null ? "checked" : "") + " />\n"); outStr.append("    " + noDateLabel + "\n"); outStr.append("  </p>\n"); outStr.append("  <p>\n"); outStr.append("    <input\n"); outStr.append("      name=\"" + radioButtonGroupName + "\"\n"); outStr.append("      type=\"radio\"\n"); outStr.append("      value=\"" + YESDATE_VALUE + "\"\n"); outStr.append(       (defaultDateValue != null ? "checked" : "") + " />\n"); outStr.append("    " + dateValueLabel + "\n"); outStr.append("    <input\n"); outStr.append("      name=\"" + nameRoot + DATETEXT_SUFFIX + "\"\n"); outStr.append("      type=\"text\"\n"); outStr.append("      class=\"date\"\n"); outStr.append("      value=\"" + defaultDateStr + "\"\n"); outStr.append("      onfocus=\n"); outStr.append("        \"if (this.value == '" + DATE_SAMPLE + "') this.value='';\n"); outStr.append("        this.style.color='black';\n"); outStr.append("        this.form." + radioButtonGroupName + "[0].checked=false;\n"); outStr.append("        this.form." + radioButtonGroupName + "[1].checked='checked'\"/>\n"); outStr.append("  </p>\n"); outStr.append("</td>\n");  return outStr.toString();
return dateSelection (request, nameRoot, title, noDateLabel, dateValueLabel, defaultDateValue, true);
  public static String dateSelection    (HttpServletRequest request,     String             nameRoot,     String             title,     String             noDateLabel,     String             dateValueLabel,     Date               defaultDateValue)  {    StringBuffer outStr = new StringBuffer();    String defaultDateStr;            if (defaultDateValue == null)    {      defaultDateStr = DATE_SAMPLE;    }    else    {      SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);      defaultDateStr = formatter.format(defaultDateValue);    }        String radioButtonGroupName = nameRoot + HASDATE_SUFFIX;        outStr.append("<td>" + title + "</td>\n");    outStr.append("<td>\n");        outStr.append(displayErrorMessage(request, nameRoot));        outStr.append("  <p>\n");    outStr.append("    <input\n");    outStr.append("      name=\"" + radioButtonGroupName + "\"\n");    outStr.append("      type=\"radio\"\n");    outStr.append("      value=\"" + NODATE_VALUE + "\"\n");    outStr.append(       (defaultDateValue == null ? "checked" : "") + " />\n");    outStr.append("    " + noDateLabel + "\n");    outStr.append("  </p>\n");    outStr.append("  <p>\n");    outStr.append("    <input\n");    outStr.append("      name=\"" + radioButtonGroupName + "\"\n");    outStr.append("      type=\"radio\"\n");    outStr.append("      value=\"" + YESDATE_VALUE + "\"\n");    outStr.append(       (defaultDateValue != null ? "checked" : "") + " />\n");    outStr.append("    " + dateValueLabel + "\n");    outStr.append("    <input\n");    outStr.append("      name=\"" + nameRoot + DATETEXT_SUFFIX + "\"\n");    outStr.append("      type=\"text\"\n");    outStr.append("      class=\"date\"\n");    outStr.append("      value=\"" + defaultDateStr + "\"\n");    outStr.append("      onfocus=\n");    outStr.append("        \"if (this.value == '" + DATE_SAMPLE + "') this.value='';\n");    outStr.append("        this.style.color='black';\n");    outStr.append("        this.form." + radioButtonGroupName + "[0].checked=false;\n");    outStr.append("        this.form." + radioButtonGroupName + "[1].checked='checked'\"/>\n");    outStr.append("  </p>\n");    outStr.append("</td>\n");        return outStr.toString();  }