-3
        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)
Edgar Buchvalov
  • 257
  • 2
  • 12
  • 22

2 Answers2

1

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 Remontas constructor - is that deliberate?

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
0

use this code, it worked for me ps.setString(1, ((JTextField)txtDate.getDateEditor().getUiComponent()).getText());

Dipesh Shrestha
  • 57
  • 1
  • 1
  • 9