Home > Database > Mysql Tutorial > mysql-时间为空值的设为0000-00-00怎么插入到数据库中

mysql-时间为空值的设为0000-00-00怎么插入到数据库中

WBOY
Release: 2016-06-06 09:38:25
Original
1901 people have browsed it

mysqljson

Java读取json数据到MySQL中,json中的regist_time为String ,数据库中的为Date,当regist_time为空时插入不到数据库,所有regist_time为空时,时间设为0000年00月00日,还是不对,
if(regist_time=="") regist_time="0000年00月00日";
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
Date date =format.parse(regist_time);
java.sql.Date sqlDate=new java.sql.Date(date.getTime());

return sqlDate;

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