Find the difference between two dates and date are stored in string type
<p>I have made an application in java where I have form which has "From date" &amp; "To date".
I want to check whether the selected date from "To date" is coming after the "From date" 
Example: If the date selected from "From date" is 2013-03-18(YY-mm-dd) then the date selected from the "To date" should be any date after/greater than 2013-03-18. To get the date i have used JXDatePicker, and to convert the date in yy-mm-dd format i have used
 <code>SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy/MM/dd")</code>
I need this to validate, So if the "To date" is > "From date" then it should display the JOptionPane with error message.</p>

<p>Edit> I have tried getting the date from the JXDatePicker in the </p>

<pre><code>Date fd = (Date) from.getDate();
</code></pre>

<p>and this is executed when the date is selected from the JXDatePicker , also i have tried printing the date, But when I run the application I am getting error as follows:</p>

<pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date
    at rejectionCategorisedReport$1.actionPerformed(rejectionCategorisedReport.java:154)
    at org.jdesktop.swingx.JXDatePicker.fireActionPerformed(JXDatePicker.java:916)
    at org.jdesktop.swingx.JXDatePicker.commitEdit(JXDatePicker.java:706)
    at org.jdesktop.swingx.plaf.basic.BasicDatePickerUI.commit(BasicDatePickerUI.java:859)
    at org.jdesktop.swingx.plaf.basic.BasicDatePickerUI$Handler.monthViewActionPerformed(BasicDatePickerUI.java:1327)
    at org.jdesktop.swingx.plaf.basic.BasicDatePickerUI$Handler.actionPerformed(BasicDatePickerUI.java:1302)
    at org.jdesktop.swingx.JXMonthView.fireActionPerformed(JXMonthView.java:1788)
    at org.jdesktop.swingx.JXMonthView.commitSelection(JXMonthView.java:1686)
    at org.jdesktop.swingx.plaf.basic.BasicMonthViewUI$Handler.mouseReleased(BasicMonthViewUI.java:2053)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
</code></pre>

<p>Can someone please help me and tell me what the problem is ?</p>
