private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// Get Date 1
try {
Date d1 = df.parse("2000-02-01");
} catch(java.text.ParseException pe) {
JOptionPane.showMessageDialog(null, "Your parse got PWNT");
}
// Get Date 2
try {
Date d2 = df.parse("2001-03-02");
} catch(java.text.ParseException pe) {
JOptionPane.showMessageDialog(null, "Your parse got PWNT");
}
String relation;
if (d1.equals(d2))
relation = "the same date as";
else if (d1.before(d2))
relation = "before";
else
relation = "after";
System.out.println(d1 + " is " + relation + ' ' + d2);
}
I am trying to comapre then display then in a text box using Try but it cannot read the varaibles because the operatin is outside the try is there anyway around this or a different way of doing this?
Thanks.