What's up all? I am having a problem with a function I created. I have an array of dates, and I'm simply trying to format them in mm/dd/yyyy format. This is my function.
public String[] convertToDate(Object[] objArray) {
int i;
String[] tmpArray = new String[objArray.length];
Date d;
Format df = new SimpleDateFormat("MM/dd/yyyy"
;
for (i=0; i<objArray.length; i++) {
try {
if ((objArray[ i ]!=null) && (objArray[ i].toString()!=""
) {
d = Date.valueOf(objArray[ i].toString());
tmpArray[ i]=df.format(d);
} else {
tmpArray[ i]="";
}
} catch (IllegalArgumentException s) {
System.out.println("Illegal Date Format"
;
}
}
return tmpArray;
} //End convertToDate()
The problem is, when I get to the line... d = Date.valueOf(objArray[ i].toString());... my program throws an IllegalArgumentException.. Any ideas on what I'm doing wrong?
public String[] convertToDate(Object[] objArray) {
int i;
String[] tmpArray = new String[objArray.length];
Date d;
Format df = new SimpleDateFormat("MM/dd/yyyy"
for (i=0; i<objArray.length; i++) {
try {
if ((objArray[ i ]!=null) && (objArray[ i].toString()!=""
d = Date.valueOf(objArray[ i].toString());
tmpArray[ i]=df.format(d);
} else {
tmpArray[ i]="";
}
} catch (IllegalArgumentException s) {
System.out.println("Illegal Date Format"
}
}
return tmpArray;
} //End convertToDate()
The problem is, when I get to the line... d = Date.valueOf(objArray[ i].toString());... my program throws an IllegalArgumentException.. Any ideas on what I'm doing wrong?