customerized convert from field type to DB field's type
@LastModifiedDate
@Convert(converter = LocalDateTime2TimestampConverter.class)
@Slf4j
public class LocalDateTime2TimestampConverter implements
AttributeConverter<LocalDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(LocalDateTime ld) {
return ld == null ? null : new Timestamp(ld.toDateTime().getMillis());
}
@Override
public LocalDateTime convertToEntityAttribute(Timestamp ts) {
if (ts != null) {
try {
return LocalDateTime.fromDateFields(ts);
} catch (IllegalArgumentException ex) {
log.warn("Can't convert {} to LocalDate", ts, ex);
}
}
return null;
}
}
customerized convert from field type to DB field's type的更多相关文章
- 使用elasticsearch启动项目报错failed to load elasticsearch nodes 。。。。。No type specified for field [name]
failed to load elasticsearch nodes .....No type specified for field [name]翻译: 加载ElasticSearch节点失败... ...
- JAVA错误提示:The operation is not applicable to the current selection.Select a field which is not declared as type variable or a type that declares such fields.
平时没怎么注意,今天用Eclipse自动生成Set Get方法时提示错误,错误信息如下: The operation is not applicable to the current selectio ...
- Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2020-02-06'; nested exception is java.lang.IllegalArgumentException]解决
今天做springbook项目前端输入日期传到数据库保存报了一下错误 Whitelabel Error Page This application has no explicit mapping fo ...
- JAVA反射系列之Field,java.lang.reflect.Field使用获取方法
JAVA反射系列之Field,java.lang.reflect.Field使用获取方法. 转载https://my.oschina.net/u/1407116/blog/209383 摘要 ja ...
- 【spring boot】spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date]
spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [jav ...
- Jpa自定义查询报错(Failed to convert from type [java.lang.Object[]] to type)
Jpa自定义查询报错 问题背景 今天遇到一个奇怪的报错"Failed to convert from type [java.lang.Object[]] to type",这个报错 ...
- [Antd-vue] Warning: You cannot set a form field before rendering a field associated with the value.
在用ant-design-vue的框架中,使用到了这种场景,就是点击编辑按钮,弹出modal模态框,渲染modal模态框中的form表单页面,并给表单赋值,但是在给表单赋值的时候,总是会报错. 错误提 ...
- (转)织梦dedecms模板。如何让type='image'和不带type='image'的文章同时出现在列表里。
“节日歌圩”栏目是有内容的,但是文章没有缩略图所以没有在频道首页显示出来,我现在想要有缩略图的文章自然显示,没有缩略图的文章也能出现标题列表(依然按照一行4个标题,可以用一张“无缩略图”的图片来代替缩 ...
- No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, org.springframework.boot.logging.LogLevel>]
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...
随机推荐
- MSSql得到表的结构和字段
得到数据库中所有的表 select name from sysobjects where xtype='u' and name='{0}' 1.获取表的基本字段属性 --获取SqlServer中表结构 ...
- matlab search path
What Is the MATLAB Search PathThe search path, or path is a subset of all the folders in the file sy ...
- HDU 4901 The Romantic Hero (计数DP)
The Romantic Hero 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/E Description There is ...
- ds18b20里的 温度值正负判断 为什么要判断大于6348 ,为什么取这个值?
http://zhidao.baidu.com/question/576118682.html?quesup2&oldq=1
- JAVA 反射应用:properties2Object
MixAll.java import java.lang.reflect.Method; import java.util.Properties; public class MixAll { /** ...
- Unity3D细节整理:AssetBundle对应的各种格式文件的类型
我们打包AssetBundle后,Unity3D会根据文件的后缀名将文件转换为特定的类型对象存储起来,我们后期获取时需要根据这些类型取出打包的数据,这里记录下不同后缀文件打包后的类型. 文本格式 支持 ...
- c# 如何使用DLL的config文件中的信息
我知道用c#编写的exe程序可以读取config文件中的配置信息,比如Test.exe,可以在与Test.exe相同目录下放置一个config文件:Test.exe.config,用System.Co ...
- JQuery要点(一)
简介: jQuery Mobile 是用于创建移动 Web 应用的前端开发框架. jQuery Mobile 可以应用于智能手机与平板电脑. jQuery Mobile 使用 HTML5 & ...
- google域名邮箱申请 gmail域名邮箱申请(企业应用套件)指南
近期一直有朋友问我怎么注冊域名邮箱,于是整理出来,贴出来吧.已经非常具体了,你能够直接对比着做了.什么是域名邮箱? 假设你有一个自己的域名,通过对域名dns进行设置,创建以自己的域名作为邮箱后缀的邮箱 ...
- C++ XML解析之TinyXML篇[转]
最 近使用TinyXML进行C++ XML解析,感觉使用起来比较简单,很容易上手,本文给出一个使用TinyXML进行XML解析的简单例子,很多复杂的应用都可以基于本例子的方法来完 成.以后的文章里会讲 ...