DateFormat dateformatYYYYMMDD = new SimpleDateFormat("yyyyMMdd");
String nowYYYYMMDD = new String( dateformatYYYYMMDD.format( dateChooser.getDate()) );
textField_1.setText(nowYYYYMMDD);
i tried this way but i cant get date from datechooser error:
java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1032)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:785)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:778)
at java.text.DateFormat.format(DateFormat.java:314)
at Remontas.jbInit(Remontas.java:239)
at Remontas.<init>(Remontas.java:176)
at Remontas.main(Remontas.java:161)
My guess is that
dateChooser.getDate()is returning null, given the stack trace. We can't tell why that is from the code you've given us.Note that you're calling this from your
Remontasconstructor - is that deliberate?