如何用kettle将Excel中的String日期转换成Date类型,保存到数据库中?
var s = " 2005-12-15 09:41:30 " ;
var d = new Date(Date.parse(s.replace( /-/ g, " / " )));
// 创建jsDate对象参数格式可有以下几种
new Date("month dd,yyyy hh:mm:ss");
new Date("month dd,yyyy");
new Date(yyyy,mth,dd,hh,mm,ss);
new Date(yyyy,mth,dd);
new Date(ms);
// 如果不是这种格式的字符需进行格式化
// 年月日格式字符串转日期格式
new Date(Date.parse("2007年11月11日".replace('年','-').replace('月','-').replace('日','')));
// 其余字符串符合xxxx-xx-xx或xxxx/xx/xx直接扔进Date对象即可
new Date("xxxx-xx-xx");
只要是合法的字符串日期格式,不用转换直接保存就可以。
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps: 问答会员年卡【8折】购 ,限时加赠IT实体书,即可 享受50次 有问必答服务,了解详情>>>https://t.csdnimg.cn/RW5m