开发者

java datechooser how to get date

        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(DateFor开发者_如何学JAVAmat.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 Remontas constructor - is that deliberate?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜