Date to SQLDate
<p>I have a simple function converts <code>date</code> to <code>java.sql.date</code>.</p>

<pre><code>public static java.sql.Date getSqlDate(String dateStr, String format) {
    java.sql.Date dt = null;
    Date date;
    SimpleDateFormat df = new SimpleDateFormat(format);
    ParsePosition pos = new ParsePosition(0);
    date = df.parse(dateStr, pos);
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    dt = java.sql.Date.valueOf(cal.get(cal.YEAR) + "-" + (cal.get(cal.MONTH)+1)
            + "-" + cal.get(cal.DATE));
    return dt;
}
</code></pre>

<p>The problem is when i call this function with the following i'm getting an <code>IllegalArgumentException</code>.</p>

<p>"2008-02-04", "yyyy-dd-MM"</p>

<p>May be I'm not able to catch error in the code, hence wanted to have another set of eyes looking into this and correct me please...</p>

<p>-- M</p>
