网站首页 > 技术文章 正文
时间日期的前后台不一致问题,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
就可以了。
猜你喜欢
- 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数据库定时器用法
- 2024-10-30 oracle三大类型(varchar2,number,date)与隐式数据类型转换
- 2024-10-30 SQL日期函数大全 看这一篇就够 sql日期函数的使用方法
- 2024-10-30 oracle——ora-01839 指定的日期无效,interval '2' month的问题
- 2024-10-30 数据库中常用的日期函数 数据库日期型
你 发表评论:
欢迎- 637℃几个Oracle空值处理函数 oracle处理null值的函数
- 629℃Oracle分析函数之Lag和Lead()使用
- 618℃0497-如何将Kerberos的CDH6.1从Oracle JDK 1.8迁移至OpenJDK 1.8
- 613℃Oracle数据库的单、多行函数 oracle执行多个sql语句
- 612℃Oracle 12c PDB迁移(一) oracle迁移到oceanbase
- 603℃【数据统计分析】详解Oracle分组函数之CUBE
- 591℃最佳实践 | 提效 47 倍,制造业生产 Oracle 迁移替换
- 577℃Oracle有哪些常见的函数? oracle中常用的函数
- 最近发表
- 标签列表
-
- 前端设计模式 (75)
- 前端性能优化 (51)
- 前端模板 (66)
- 前端跨域 (52)
- 前端缓存 (63)
- 前端aes加密 (58)
- 前端脚手架 (56)
- 前端md5加密 (54)
- 前端路由 (61)
- 前端数组 (73)
- 前端js面试题 (50)
- 前端定时器 (59)
- 前端获取当前时间 (50)
- Oracle RAC (76)
- oracle恢复 (77)
- oracle 删除表 (52)
- oracle 用户名 (80)
- oracle 工具 (55)
- oracle 内存 (55)
- oracle 导出表 (62)
- oracle约束 (54)
- oracle 中文 (51)
- oracle链接 (54)
- oracle的函数 (58)
- 前端调试 (52)
本文暂时没有评论,来添加一个吧(●'◡'●)