MusicSys:unsolved:
Hello Could someone tell me which (if any combination of code to use to put a
date in a derby db using a JFormattedTextField?
createBooking ...etc
...,
book_date DATE,
....,
...
here are the many tries I have so far
if (i == 3) {
//I started with this did not work:
/*
* import java.sql.Time;
import java.util.Date;
*/
//bookingBean.setBookDate((java.sql.Date) txtFieldArray[i].getValue());//Input=1111-11-11
//derby db
//the bean = public Date bookDate;
/*
* public static final String MASKFORMAT = "##/##/####";
//public static final String SIMPLEDATEFORMATMASK = "MM/dd/yyyy HH:mm:ss a";<----not using this one
public static final String SIMPLEDATEFORMATMASK = "MM/dd/yyyy"; <-----------using this thought it was .SHORT?
private SimpleDateFormat sdf = new SimpleDateFormat(SIMPLEDATEFORMATMASK);
*/
//JFormattedTextField with mask and verifier ##/##/#### and MM/dd/yyyy
//bookingBean.setBookDate((java.util.Date) txtFieldArray[i].getValue());//Input=11/11/2010
String d = (String) txtFieldArray[i].getValue();
Date dStr=DateFormat.getDateInstance(DateFormat.SHORT).parse(d);
bookingBean.setBookDate(dStr);
//Date dStr=DateFormat.getDateInstance(DateFormat.SHORT).parse(d);
//DateFormat.getDateInstance(DateFormat.SHORT)
// Date dStr=DateFormat.getDateInstance().parse(d);
// Date dStr = DateFormat.getDateInstance().parse(d);
}
The latest error: using the uncommentd code;
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1214)
at java.text.DateFormat.parse(DateFormat.java:335)
at view.formActions.RegisterFormActions.bookingRegisterAction(RegisterFormActions.java:979)
at view.content.masterGuidePanels.guide.MasterRegisterForm.formFactory(MasterRegisterForm.java:529)
at view.forms.registerForms.BookingRegisterForm.submitBtnAction(BookingRegisterForm.java:561)
at view.forms.registerForms.BookingRegisterForm.actionPerformed(BookingRegisterForm.java:315)
Here is an err of the SimpleDateFormat code :
public Date parse(String text, ParsePosition pos)
{
int start = pos.index;
int oldStart = start;
-------> int textLength = text.length(); stops here: I tried sending two params (String,int) did not work
Thank