public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AddStudentForm addStudentForm = (AddStudentForm) form;
PersonDAO personDAO = new PersonDAO();
Student student = new Student();
String birth = addStudentForm.getBirthdayYear() + "-"+ addStudentForm.getBirthdayMonth() +
"-"+ addStudentForm.getBirhthdayDay();
student.setUsername(addStudentForm.getUsername());
student.setPassword(addStudentForm.getPassword());
student.setSex(addStudentForm.getSex());
try {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");//固定的格式
Date date = sd.parse(birth);//将字符转化为DATE类型
student.setBirthday(date);
} catch (ParseException e) {
System.out.println("插入失败插入失败插入失败插入失败插入失败");
}
student.setGrade(addStudentForm.getGragde());
personDAO.insertStudentOrTeacher(student);
return mapping.findForward("ok");
}
/*************************************************************************/
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=new Date();
String toLocaleString = date.toLocaleString();
article.setSavetime(sd.parse(toLocaleString));
/*************************************************
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=new Date();
String dd=sd.format(date);
posted on 2007-10-18 19:25
Crying 阅读(405)
评论(0) 编辑 收藏 所属分类:
数据库