1
I am unable to do the user input. I want the program to make the difference of days between today’s date and the date typed by the user. The program has more implementations but it’s just this part that isn’t working.
private JTextField dataVencimento;
dataVencimento = new JTextField(20)
container.add(dataVencimento);
...
DateTime hoje = new DateTime();
DateTime dataVencimento = new DateTime();
Days daysBetween = Days.daysBetween(dataVencimento, hoje);
JOptionPane.showMessageDialog(null, "Dias de diferença: " + daysBetween,
"Atraso", JOptionPane.INFORMATION_MESSAGE);
You can also use a
JFormattedTextField
, with a mask that allows only the date format, and using the method I suggested, I believe it is even better than having to use 3 components. You will have to validate the 3 to get to if some invalid value has been passed, or if the field is coming blank. With the component I mentioned, you do this only once. Another option is to use the componentJCalendar
, who already does it all for you.– user28595
It’s true, I need to validate each one, not to mention that it gets boring three entries instead of just one. Once again it was worth.
– Edson F.