Java:
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd HH:mm:ss.SSS
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
JS
yyyy-MM-dd hh:mm:ss.S
yyyy-M-d h:m:s.S
js时间转字符串:
(new Date()).format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 (new Date()).format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18js字符串转时间 :
new Date()支持的格式:
new Date("yyyy/MM/dd")
new Date("yyyy/MM/dd hh:mm:ss")
new Date(ms)
Dorado7已支持yyyy-MM-dd 无需调用额外转换dateStr.replace(/-/g,"/")
new Date("yyyy-MM-dd hh:mm:ss")
var createdDate = new Date("2022-11-08 12:36:02"); view.get("#dateDS").getData("#").set("createdDate", createdDate);Oracel:
yyyy-MM-dd HH24:mi:ss
to_char(createdDate,'yyyy-MM-dd')
to_date('2021-03-01','yyyy-MM-dd')
sysdate
MySQL:
%Y-%m-%d %H:%i:%S
date_format(createdDate,'%Y-%m-%d')
str_to_date('2021-03-01','%Y-%m-%d')
sysdate()
获取上个月
DATE_SUB(curdate(), INTERVAL 1 MONTH)
//查看上个月数据 SELECT * FROM content_publish WHERE date_format(publish_time, '%Y %m') = date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y %m')MySQL加1天
select date_add(now(), interval 1 day); -加1天 select date_add(now(), interval 1 hour); -加1小时 select date_add(now(), interval 1 minute); -加1分钟 select date_add(now(), interval 1 second); -加1秒 select date_add(now(), interval 1 microsecond); -加1毫秒 select date_add(now(), interval 1 week); -加1周 select date_add(now(), interval 1 month); -加1月 select date_add(now(), interval 1 quarter); -加1季 select date_add(now(), interval 1 year); -加1年 date_add() date_sub()Dorado7:
Y-m-d H:i:s
调出时分秒
DateTime
IDEA date日期保存时报错
添加标注
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
或
@DateTimeFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") @Column(name = "valid_start") public Date getValidStart() { return validStart; } public void setValidStart(Date validStart) { this.validStart = validStart; } @DateTimeFormat(pattern = "yyyy-MM-dd") @Column(name = "carmaintenance") public Date getCarmaintenance() { return carmaintenance; } public void setCarmaintenance(Date carmaintenance) { this.carmaintenance = carmaintenance; }另外:MySQL字符串拼接CONCAT
CONCAT("http://",a.product_coverimg)
CST时间转Date
//CST时间转Date String expriseTime = "Tue May 31 12:48:01 CST 2022"; SimpleDateFormat dfCst = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK); Date expriseTimeD = null; try { expriseTimeD = dfCst.parse(expriseTime); } catch (ParseException e) { e.printStackTrace(); } System.out.println(expriseTimeD); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(df.format(expriseTimeD));