网站首页 > 技术文章 正文
时间日期的前后台不一致问题,oracle数据库 插入和查询的时候拿到的时间和存储值不一致,今天直接上代码。
一、前台格式化代码
//将后台传过来的 日期时间 格式化方法 //显示完整的 yyyy-mm-dd hh:mm:ss function formatime(oldDate) { if(!oldDate){ return; } if(typeof(oldDate) === 'string'){ //这里要注意你的格式是什么,这个CST不要写错了 oldDate = oldDate.replace("CST","GMT+0800"); var now = new Date(oldDate); var year = now.getFullYear(); var month = now.getMonth()+1; var day = now.getDate(); var hours = now.getHours(); if(hours <= 9){ hours = "0" + hours; } var minutes = now.getMinutes(); if(minutes <= 9){ minutes = "0" + minutes; } var seconds = now.getSeconds(); if(seconds <= 9){ seconds = "0" + seconds; } if(month <= 9){ month = "0" + month; } if(day <= 9){ day = "0" +day; } return "" + year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds + ""; } } 二、后台数据库插入问题 oracle 数据库在你的 类中 Date 类型上面加上 1. @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 2.@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss" ) 这两个注解
3、在 oracle 插入和查询数据库的时候 xml 文件中 date 类型的去掉 jdbcType = date
就可以了。
猜你喜欢
- 2025-08-01 OpenAI每年向甲骨文支付300亿美元数据中心服务费用
- 2025-08-01 分布式数据库里的时间戳
- 2025-08-01 甲骨文签署多项大型云协议,其一未来可贡献超300亿美元年收入
- 2025-08-01 OpenAI与甲骨文Oracle宣布4.5GW规模“星际之门”项目合作
- 2024-10-30 oracle——字符串转(日期或者日期字符串)
- 2024-10-30 Ask Oracle 天秤座1月份,坚持理想与信念,成功就在不远方
- 2024-10-30 使用ORA_ROWSCN伪列获取表最后的DML时间
- 2024-10-30 Oracle数据库小基础 oracle数据库基础教程孙风栋答案
- 2024-10-30 美创科技运维日记|关于Oracle数据库的软件支持周期的那些事
- 2024-10-30 Oracle数据库定时器Job oracle数据库定时器用法
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 前端设计模式 (75)
- 前端性能优化 (51)
- 前端模板 (66)
- 前端跨域 (52)
- 前端缓存 (63)
- 前端aes加密 (58)
- 前端脚手架 (56)
- 前端md5加密 (54)
- 前端路由 (61)
- 前端数组 (73)
- 前端js面试题 (50)
- 前端定时器 (59)
- Oracle RAC (76)
- oracle恢复 (77)
- oracle 删除表 (52)
- oracle 用户名 (80)
- oracle 工具 (55)
- oracle 内存 (55)
- oracle 导出表 (62)
- oracle约束 (54)
- oracle 中文 (51)
- oracle链接 (54)
- oracle的函数 (58)
- oracle面试 (55)
- 前端调试 (52)
本文暂时没有评论,来添加一个吧(●'◡'●)