Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need code to obtain Date values from database then set it as a string. Can anyon

ID: 657540 • Letter: N

Question

 Need code to obtain Date values from database then set it as a string. Can anyone tell me why the below code isn't functioning properly?  ********************************************************  Date d = rs.getDate("PatientBirthDate");  DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); String date = df.format(d);  while (rs.next()) {     pid.setText(String.valueOf(rs.getInt("PatientID")));     ssn.setText(rs.getString("PatientSSN"));     firstname.setText(rs.getString("PatientFname"));     lastname.setText(rs.getString("PatientLname"));     gender.setText(rs.getString("PatientGender"));    // dob.setText(date);     streetnum.setText(rs.getString("PatientStreetNo"));     streetname.setText(rs.getString("PatientStreetName"));     city.setText(rs.getString("PatientCity"));     state.setText(rs.getString("PatientState"));     zip.setText(rs.getString("PatientZip"));     homephone.setText(rs.getString("PatientHomePhone"));     cellphone.setText(rs.getString("PatientCellPhone"));     email.setText(rs.getString("PatientEmailAddress"));     inspolicy.setText(rs.getString("InsurancePolicyNumber"));     inscompany.setText(String.valueOf(rs.getInt("InsuranceCompID"))); 

Explanation / Answer

DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
String in = r.getTimestamp("PatientBirthDate");
Date d = df.parse(in);

you can try to put column nos.instead of names other than that i dont see any error.But never your current code should work

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote