Date类型数据的获取与转换与单选框按钮数据的获取
2015-08-01 16:12
337 查看
1.datel类型的数据的获取与转换:注:为java.util.Date
(1)_Impl.java conn = DBOperator.getConnection();
String sql = "insert into competitor values(?,?,?,?,?,?,?,?)";
java.sql.Date sqlDate = new java.sql.Date(ct.getBirth().getTime());
System.out.println("sqlDate="+sqlDate);
pst = conn.prepareStatement(sql);
pst.setInt(1, ct.getId());
pst.setString(2, ct.getUsername());
pst.setString(3, ct.getPassword());
pst.setString(4, ct.getRealname());
pst.setInt(5, ct.getMatchage());
pst.setDate(6, sqlDate );
pst.setString(7, ct.getAddress());
pst.setString(8, ct.getSex());
(2).__.java(servlet)
int id = Integer.parseInt(request.getParameter("id"));
String username = request.getParameter("username");
String password = request.getParameter("password");
String realname= request.getParameter("realname");
int matchage=Integer.parseInt(request.getParameter("matchage"));
String birth = request.getParameter("birth");
String sex= request.getParameter("sex");
String address= request.getParameter("address");
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
Date dirths=null;
try {
dirths = sim.parse(birth);
CompetitorManager sm = new CompetitorManagerImpl();
Competitor ct = new Competitor();
ct.setId(id);
ct.setUsername(username);
ct.setPassword(password);
ct.setRealname(realname);
ct.setMatchage(matchage);
ct.setBirth(dirths);
ct.setAddress(address);
ct.setSex(sex);
boolean flag = sm.add(ct);
if(flag == true)
2.单选框按钮的数据的获取。
(1)_.jsp
性 别<input type="radio" value="男" name="sex" >男 <input type="radio" value="女" name="sex">女<br><br>
(2). int id = Integer.parseInt(request.getParameter("id"));
String username = request.getParameter("username");
String password = request.getParameter("password");
String realname= request.getParameter("realname");
int matchage=Integer.parseInt(request.getParameter("matchage"));
String birth = request.getParameter("birth");
String sex= request.getParameter("sex");
String address= request.getParameter("address");
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
Date dirths=null;
try {
dirths = sim.parse(birth);
System.out.println("dirths==="+dirths);
CompetitorManager sm = new CompetitorManagerImpl();
Competitor ct = new Competitor();
ct.setId(id);
ct.setUsername(username);
ct.setPassword(password);
ct.setRealname(realname);
ct.setMatchage(matchage);
ct.setBirth(dirths);
ct.setAddress(address);
ct.setSex(sex);
boolean flag = sm.add(ct);
(1)_Impl.java conn = DBOperator.getConnection();
String sql = "insert into competitor values(?,?,?,?,?,?,?,?)";
java.sql.Date sqlDate = new java.sql.Date(ct.getBirth().getTime());
System.out.println("sqlDate="+sqlDate);
pst = conn.prepareStatement(sql);
pst.setInt(1, ct.getId());
pst.setString(2, ct.getUsername());
pst.setString(3, ct.getPassword());
pst.setString(4, ct.getRealname());
pst.setInt(5, ct.getMatchage());
pst.setDate(6, sqlDate );
pst.setString(7, ct.getAddress());
pst.setString(8, ct.getSex());
(2).__.java(servlet)
int id = Integer.parseInt(request.getParameter("id"));
String username = request.getParameter("username");
String password = request.getParameter("password");
String realname= request.getParameter("realname");
int matchage=Integer.parseInt(request.getParameter("matchage"));
String birth = request.getParameter("birth");
String sex= request.getParameter("sex");
String address= request.getParameter("address");
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
Date dirths=null;
try {
dirths = sim.parse(birth);
CompetitorManager sm = new CompetitorManagerImpl();
Competitor ct = new Competitor();
ct.setId(id);
ct.setUsername(username);
ct.setPassword(password);
ct.setRealname(realname);
ct.setMatchage(matchage);
ct.setBirth(dirths);
ct.setAddress(address);
ct.setSex(sex);
boolean flag = sm.add(ct);
if(flag == true)
2.单选框按钮的数据的获取。
(1)_.jsp
性 别<input type="radio" value="男" name="sex" >男 <input type="radio" value="女" name="sex">女<br><br>
(2). int id = Integer.parseInt(request.getParameter("id"));
String username = request.getParameter("username");
String password = request.getParameter("password");
String realname= request.getParameter("realname");
int matchage=Integer.parseInt(request.getParameter("matchage"));
String birth = request.getParameter("birth");
String sex= request.getParameter("sex");
String address= request.getParameter("address");
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
Date dirths=null;
try {
dirths = sim.parse(birth);
System.out.println("dirths==="+dirths);
CompetitorManager sm = new CompetitorManagerImpl();
Competitor ct = new Competitor();
ct.setId(id);
ct.setUsername(username);
ct.setPassword(password);
ct.setRealname(realname);
ct.setMatchage(matchage);
ct.setBirth(dirths);
ct.setAddress(address);
ct.setSex(sex);
boolean flag = sm.add(ct);
相关文章推荐
- dos 日期时间格式设置使用小结(Date和Time)
- DOS批处理之DATE命令的使用方法详解
- 如何解决ORA-01843与NLS_DATE_FORMAT问题
- ExtJs的Date格式字符代码
- PHP中Date获取时间不正确怎么办
- Insert Date and Time into Access
- JavaScript通过this变量快速找出用户选中radio按钮的方法
- javascript radio list的实现细节(多浏览器兼容)
- 利用JavaScript更改input中radio和checkbox样式
- jquery获取radio值(单选组radio)
- 解决jquery实现的radio重新选中的问题
- Jquery判断radio、selelct、checkbox是否选中及获取选中值方法总结
- jQuery实现自定义checkbox和radio样式
- JQuery判断radio是否选中并获取选中值的示例代码
- 三种取消选中单选框radio的方法
- 新老版本juqery获取radio对象的方法
- jquery获取input表单值的代码
- 利用jquery操作Radio方法小结
- Shell脚本实现随机数多种方法介绍(date、random、uuid)
- select、radio表单回显功能实现避免使用jquery载入赋值