java 存取oracle数据库日期数据
//存日期数据
SimpleDateFormat sdf = new SimpleDateFormate("yyyy-MM-dd"); //中间是大写的MM
String date = sdf.format(new Date()); //Date 为util包的类型
String sql = "insert into scott.bankstatement (id,acction,txdate,amt,toaccno,fromaccno ) values (seqOnbank.nextval, " +\'storeM\',to_date(\'"+date+"\',\'yyyy-mm-dd\'),"+balance+","+accno+","+accno+")";
.....
//如果用preparedStatement 类的setDate()确定日期值得时候,讲字符串转为sql。Date日期类型
String dateStringToParse = “2013-09-11”;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
ry{
java.util.Date date =df.parse(dateStringToParse);
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
System.out.println(sqlDate.getTime());
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
//取日期数据
String date = "\'1991-09-01\'"
String sql = "select txdate from scott.bankstatement where txdate = " + date;