I have this section:
which is passed information from here:public void set_doh(int new_m, int new_d, int new_y) { String datestring = Integer.toString(new_m) + "/" + Integer.toString(new_d) + "/" + Integer.toString(new_y); System.out.println(datestring); DateFormat DOB = new SimpleDateFormat("m/d/yyyy"); try { Date convertedDate = DOB.parse(datestring); this.doh = convertedDate; } catch (ParseException e) { System.out.println("Failed to parse"); } }
The datestring is printed in the correct format in the first block but when it goes to convert it into Date format I get:employee1.set_doh( Integer.parseInt(scanner.nextLine()),Integer.parseInt(scanner.nextLine()),Integer.parseInt(scanner.nextLine()) ); // int
E:\Java Project\Employee.java:145: error: incompatible types Date convertedDate = DOB.parse(datestring); ^ required: Date found: java.util.Date 1 error
Now, I have a Date.java class in the same folder which was given to me by my instructor and I'm supposed to use that in conjunction with a Dateutil.java she gave me as well. I've noticed that if I remove Date.java from the folder this section of the code will work but then I cannot use the Dateutil.java properly, which is necessary to compare the current date with the object's date.
Should I post the all the code in all three files?
Thanks for any and all help on this!