Oracle 中字段用的是Date 类型
实体类用的也是Date 类型
但jsp 页面中用的是文本框 填写日期字符串
报以下 错误:
java.lang.IllegalArgumentException
实体类用的也是Date 类型
但jsp 页面中用的是文本框 填写日期字符串
报以下 错误:
java.lang.IllegalArgumentException
解决方案 »
- tomcat 6.0 设置URIEncoding="utf-8" 后,如何取得中文?
- DAO层出现问题了
- 由电信局发给我的网费透支页面联想到的问题!!!
- 我这条学习jsp的路子对吗?
- 如何用js来区分关闭浏览器、刷新页面?急等用~~~~
- 昨天JSP for JAVA遇到的紧急问题,请回复
- JSP 动作标签param的问题,抛出异常,小弟不明白,请大哥们请教!
- 数据库里存贮一批树状的数据,要把它在WEB上显示出来,请问如何实现?
- jfreechart在xp下图片中文显示为方框的问题
- 如何用java调用word 中的公式编辑!来者给分
- 什么方式导入其他页面到当前页面时,可以采用.do访问服务器方式导入?
- swfupload控件中动态修改上传限制不好使
要转化成日期类型吧
相关转换函数可以查查API文档或GOOGLE搜索一下 很多
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
try {
this.date = sf.parse(date);
} catch (Exception e) {
e.printStackTrace();
}
}我想这样写 但是 查询数据是 又不能为对象赋值了
如果是的话那就将VO中的定义成string 接受 完了以后至于查询的问题 oracle中可以使用 oracle中日期函数转换 类似于 convert(date,'12/12/09') sybase和str_to_date('12/12/09','%M/%d/%y')mysql
我用的是struts 我不知道这种问题 怎么解决 没有思路action 中的代码:public ActionForward doRelease(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse respons) {
ConnForm connForm =(ConnForm )form;
System.out.println(connForm.getConn().getDate());jsp 页面中的代码:<form action="conn.do?operate=doRelease" method="post">
时 间:
<input type="text" name="conn.date" readonly="readonly" onclick="SelectDate(this,'yyyy-MM-dd')" id="cdate" />
直接在SQL语句中用 to_date(string s) 插入到表中!!
String datetime=request.getParameter(time);
try {
String title = request.getParameter("title");
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
Date startd = fmt.parse(datetime);
java.sql.Date startdate = new java.sql.Date(startd.getTime());
String content = request.getParameter("content");
Notice note = new Notice(title, startdate, content);
IntroduceService itds = new IntroduceService();
itds.addnote(note);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
能不能讲一下 具体的做法。怎么将String 转换成Date 类型再放入form 中。
你的做法 我又看不懂, 我用的是 Struts 来处理表单,用的是hibernate 操作数据库。好像用不上request.getParameter(time);
convert(varchar(10), date字段, 120); 120指的是日期格式为1900-01-01这种格式
select * from tbl1 where t_date = to_date(t_date,'yyyy-MM-dd');
action中取到字符串s_date="2009-11-13",select可以这么写:
select * from tbl1 where s_date = to_char(t_date,'yyyy-MM-dd');
HttpServletRequest request, HttpServletResponse respons) {
ConnForm connForm =(ConnForm )form;
System.out.println(connForm.getConn().getDate()); 以上做法为空
不是插入数据库出错 是有关hibernate 和实体类映射相关 实体类不知道用什么数据类型来对应数据库中的date 类型
public void setDate(String date) { }
public void setDate(Date date) { }
select * from tbl1 where t_date =?
这个?应该可以用Date对象赋值啊!Date对象也就是你从页面取来的String==》转换来的啊