Home > Database > Mysql Tutorial > java将日期时间字符串转成日期插入到oracle的date字段

java将日期时间字符串转成日期插入到oracle的date字段

WBOY
Release: 2016-06-07 15:23:11
Original
1501 people have browsed it

将日期时间字符字符串转成日期插入到oracle的date型的字段里, String datestring=2014-02-01 13:23:31; SimpleDateFormat sdf=new SimpleDateFormat(yyyy-MM-dd HH:mm:ss); date=sdf.parse(datestring); pstmt.setTimestamp(8, new java.sql.Timestamp(date

将日期时间字符字符串转成日期插入到oracle的date型的字段里,


String datestring="2014-02-01 13:23:31";

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

date=sdf.parse(datestring);

pstmt.setTimestamp(8, new java.sql.Timestamp(date.getTime()));

注意如果是 pstmt.setDate()则插入数据库的只有日期,没有时间。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template