Hello;
I was having a problem understanding how to collect a date dataType as 1111-11-11 from a textFiels)
and set a variable that accepts ex:public Date dob;
Is there a way to get a string from an array element and parse it to conform to the Date data type?

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException
at java.util.Date.parse(Date.java:598)
atJava.util.Date<init>(Date.java:255)
at view.forms.......
if(i==6){                               
                                AccessAllTables.getAdminBean().setDob(new java.util.Date(txtFieldArray[i].getText()));//Input=1111-11-11
                               
                            }
                            if(i==7){
                               
                                AccessAllTables.getAdminBean().setStartDate(new java.util.Date(txtFieldArray[i].getText()));//Input=1111-11-11
                              
                            }
                            if(i==8){
                               
                                AccessAllTables.getAdminBean().setEndDate(new java.util.Date(txtFieldArray[i].getText()));//Input=1111-11-11
                               
                            }

Hello
What is the best way to validate a Java form to control data to be used in a apache derby embedded db?
thanks

Check the constructor of the class java.util.Date at the API. I doubt the there is one that takes as argument the String that you are trying to pass
txtFieldArray.getText()

Check the API of java.util.Date as well as the class: java.text.SimpleDateFormat
And you will get your answers:
http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html

Thanks
I am researching spinners and JFormmatedTextFields. maybe the 3 args I need can be
produced for the Date(xxxx,xx,xx) format

Thanks
I am researching spinners and JFormmatedTextFields. maybe the 3 args I need can be
produced for the Date(xxxx,xx,xx) format

Don't use that constructor. If you have a String with this format or similar:
dd/MM/yyyy or yyyyMMdd ot MM-dd-yyyy use the simpleDateFormat.

That Date constructor is been deprecated and it is better not to use it anymore.
You can check the Calendar class, but I don't use it much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.