I have two boxes of JDateChooser
and I would like to make the following comparison:
- the user will inform the first date
- when it finishes entering the second date, I make a comparison consisting of:
- if the second date is greater than or equal to 11 days, the following message will appear:
JOptionPane.showMessageDialog (null,
" Homologation Date Must Be Less or Equal to 11 Days Regarding Date of Shutdown ");
I made a code that compares, but even when the user puts a date below the condition he is showing the message.
The following code:
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
dt1 = sdf.format(dcdataDeslig.getDate().getTime());
SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy");
dt2 = sdf1.format(dchomolog.getDate().getTime());
if (dt2.compareTo(dt1) >= 11 ) {
JOptionPane.showMessageDialog (null," Homologation Date Must Be Less or Equal to 11 Days Regarding Date of Shutdown ");
dchomolog.setDate(null);
txtdataDisp.setText("");
txtdataPg.setText("");
}
txtdataDisp.setText(dt2);
txtdataPg.setText(dt2);