@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的更多相关文章

  1. 使用elasticsearch启动项目报错failed to load elasticsearch nodes 。。。。。No type specified for field [name]

    failed to load elasticsearch nodes .....No type specified for field [name]翻译: 加载ElasticSearch节点失败... ...

  2. 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 ...

  3. 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 ...

  4. JAVA反射系列之Field,java.lang.reflect.Field使用获取方法

    JAVA反射系列之Field,java.lang.reflect.Field使用获取方法.   转载https://my.oschina.net/u/1407116/blog/209383 摘要 ja ...

  5. 【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 ...

  6. Jpa自定义查询报错(Failed to convert from type [java.lang.Object[]] to type)

    Jpa自定义查询报错 问题背景 今天遇到一个奇怪的报错"Failed to convert from type [java.lang.Object[]] to type",这个报错 ...

  7. [Antd-vue] Warning: You cannot set a form field before rendering a field associated with the value.

    在用ant-design-vue的框架中,使用到了这种场景,就是点击编辑按钮,弹出modal模态框,渲染modal模态框中的form表单页面,并给表单赋值,但是在给表单赋值的时候,总是会报错. 错误提 ...

  8. (转)织梦dedecms模板。如何让type='image'和不带type='image'的文章同时出现在列表里。

    “节日歌圩”栏目是有内容的,但是文章没有缩略图所以没有在频道首页显示出来,我现在想要有缩略图的文章自然显示,没有缩略图的文章也能出现标题列表(依然按照一行4个标题,可以用一张“无缩略图”的图片来代替缩 ...

  9. 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 ...

随机推荐

  1. 20150913K-means聚类

    1.聚类的思想: 将一个有N个对象的数据集,构造成k(k<=n)个划分,每个划分代表一个簇.使得每个簇包含一个对象,每个对象有且仅属于一个簇.对于给定的k,算法首先给出一个初始的划分方法,以后通 ...

  2. HDU ACM Eight

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1043 解题背景: 看到八数码问题,没有任何的想法,偶然在翻看以前做的题的时候发现解决过类似的一道题,不 ...

  3. ffmpeg 研究

    ffmpeg -codecs | grep mp3 可以查看ffmpeg是否把mp3编解码模块编译进去了. libmp3lame is the mp3 encoder for ffmpeg. It n ...

  4. thymeleaf学习

    一.简单表达格式:   thymeleaf的官方参考文档 1.变量的表达式:${...} 2.选择变量表达式:*{...} 3.信息表达:#{...} 4.链接URL表达式:@{...} 二.字面值 ...

  5. [C语言 - 10] C语言保留字

    一  数据类型关键字 12 个:    1 . char     2 . short    3 . int     4 . long     5. enum    6. float    7. dou ...

  6. opencv 矩阵的相似性对比 (图片之间比较)

    测试图片:     code: #include <opencv\cv.h> #include <opencv\highgui.h> #include <opencv\c ...

  7. SQL Select count(*)和Count(1)的区别和执行方式及SQL性能优化

    SQL性能优化:http://www.cnblogs.com/CareySon/category/360333.html Select count(*)和Count(1)的区别和执行方式 在SQL S ...

  8. SQL Server中使用convert进行日期转换

    使用 CONVERT: CONVERT (data_type[(length)],expression[,style]) 参数 expression 是任何有效的 Microsoft® SQL Ser ...

  9. java实现简单的素数判断

    素数的这个问题由来已久,大学刚接触语言的时候遇到过找素数的问题,找工作笔试的时候也遇到过素数的问题,今天就特地写这篇博文,缅怀一下. 一.什么是素数? 除了1和它本身以外不再有其他的除数整除. 二.判 ...

  10. java堆栈

    一.堆区: 1.存储的全部是对象,每个对象都包含一个与之对应的class的信息.(class的目的是得到操作指令) 2.jvm只有一个堆区(heap)被所有线程共享,堆中不存放基本类型和对象引用,只存 ...