Results 1 to 3 of 3
Thread: JXDatePicker problem
- 08-15-2011, 02:20 AM #1
Senior Member
- Join Date
- Jun 2011
- Posts
- 100
- Rep Power
- 0
JXDatePicker problem
Here's a part of my code
I tried to change my textfield into a jxdatepicker (commenting my previous textfield part), but the part on checking the date is not working, though in the other part of the code the same getDate() works fine, I can't really figure out where the problem is.Java Code:private boolean isNewSKDate() { JXDatePicker dtYear = new JXDatePicker(); SimpleDateFormat dtdf = new SimpleDateFormat ("dd/MM/yyyy"); try { qyear.setQuery("SELECT actyear FROM temp WHERE (nik = '" + txNIK.getText() + "' AND actyear = '" + Date.valueOf(dtdf.format(dtYear.getDate())) + "');"); // qyear.setQuery("SELECT actyear FROM temp WHERE (nik = '" + txNIK.getText() + "' AND actyear = '" + Date.valueOf(txYear.getText().toString().trim().replace(" 00:00:00.0", "")) + "');"); } catch (SQLException e) { e.printStackTrace(); } Component frame = null; if (qyear.getRowCount() == 0) { return true; } else if (qyear.getRowCount() > 0) { JOptionPane.showMessageDialog(frame, "Check SK Date."); return false; }; qyear.cache.clear(); return rootPaneCheckingEnabled; }
Error message that I get is :
at trndev.ActModMS.isNewSKDate(ActModMS.java:63) refers to this line :Java Code:Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException at java.sql.Date.valueOf(Unknown Source) at trndev.ActModMS.isNewSKDate(ActModMS.java:63) at trndev.ActModMS.access$8(ActModMS.java:59) at trndev.ActModMS$6.actionPerformed(ActModMS.java:449) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
qyear.setQuery("SELECT actyear FROM temp WHERE (nik = '" + txNIK.getText() + "' AND actyear = '" + Date.valueOf(dtdf.format(dtYear.getDate())) + "');");
at trndev.ActModMS.access$8(ActModMS.java:59) refers to private boolean isNewSKDate() {
at trndev.ActModMS$6.actionPerformed(ActModMS.java:44 9) refers to another part in the code where isNewSKDate() is called for checking the datetime.
Thanks in advance.Last edited by Levian; 08-15-2011 at 02:29 AM.
First is to make something usable, next is to aim for perfection which means a never ending improvements.
- 08-15-2011, 11:28 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
The sql.Date.valueOf method needs a date in the format "yyyy-MM-dd" not "dd/MM/yyyy"
- 08-16-2011, 03:21 AM #3
Senior Member
- Join Date
- Jun 2011
- Posts
- 100
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks