How to handle blank dates sent as parameters to Servlet
<p>I'm writing a webapp where there are dates to be sent to a Servlet and I want to send some blank dates and based on these dates I want to build a query. But here My problem is when I pass the parameters i.e. the dates it's working fine, And when I send blank parameters it is throwing me the below error.</p>

<pre><code>Start date got is  and end date is //Here I'm checking the output
Unparseable date: "" servlet Errotr
</code></pre>

<p>When I give in the dates it shows in console as 
<code>Start date got is (TheStartDateValue) and end date is (TheEndDateValue)</code>
 and there is no exception (since the dates are parsed). And below is my code.</p>

<pre><code>public class Controller extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            /* Date Start */
            String startDateStr = request.getParameter("startDate");
            String endDateStr = request.getParameter("endDate");
            System.out.println("Start date got is " + startDateStr + " and end date is " + endDateStr);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat print = new SimpleDateFormat("yyyy-MM-dd");
            Date startParsedDate = null, endParsedDate = null;
            String startDate = null, endDate = null;
            if (!startDateStr.equals(null) || !startDateStr.equals("")) {
                startParsedDate = sdf.parse(startDateStr);
                startDate = print.format(startParsedDate);
            }
            if (!endDateStr.equals(null) || !endDateStr.equals("")) {
                endParsedDate = sdf.parse(endDateStr);
                endDate = print.format(endParsedDate);
            }

            System.out.println(startDate + " value and " + endDate);
            /* Date End */
            DataDao dataDao = new DataDao();
            ArrayList&lt;UserBean&gt; list = dataDao.getFrameWork(startDate, endDate);
            String searchList = new Gson().toJson(list);
            response.setContentType("application/json");
            response.setCharacterEncoding("UTF-8");
            response.getWriter().write(searchList);
            System.out.println("servlet Done");
        } catch (Exception e) {
            System.err.println(e.getMessage() + " servlet Errotr");
        }
    }
</code></pre>

<p>I'm trying to handle the <code>startDateStr</code> and <code>startDateStr</code>to chweck if the input values are <code>null</code> or having some value using the below block in my above code.</p>

<pre><code>if (!startDateStr.equals(null) || !startDateStr.equals("")) {
        startParsedDate = sdf.parse(startDateStr);
        startDate = print.format(startParsedDate);
}
if (!endDateStr.equals(null) || !endDateStr.equals("")) {
        endParsedDate = sdf.parse(endDateStr);
        endDate = print.format(endParsedDate);
}
</code></pre>

<p>Please let me know where am I going wrong and how can I fix this.</p>

<p>Thanks</p>