Unparsable date exception: string to java.sql.date
<p>I have a problem with parsing a string to sql.date
This code works in my project only the first time, it will parse the date normally, but second time it throws exception.</p>

<p>I printed the date the function receives and it is the same format, for example 02.02.2016 was okey, I only changed month to 02.04.2016 and the exception was raised.   </p>

<pre><code>private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd.mm.yyyy");
private final String sqldateFormat = "yyyy-mm-dd"; 

public java.sql.Date changeDate(String date) {      
    String newDate = "";
    try {
        java.util.Date d = dateFormat.parse(date);
        dateFormat.applyPattern(sqldateFormat);
        newDate = dateFormat.format(d);

    } catch (ParseException e) {
        e.printStackTrace();
    }                   

    return java.sql.Date.valueOf(newDate);
}
</code></pre>