当前位置:网站首页>Converts a timestamp to a time in the specified format
Converts a timestamp to a time in the specified format
2022-07-03 03:12:00 【Friendship years】
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; public class JsonTimeSerializer extends JsonSerializer<Long> { private SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override public void serialize(Long datel, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException { if(datel.toString().length()<13){ datel= datel*1000L; } Date date= new Date(datel); String value = dateFormat.format(date); gen.writeString(value); } }
// Use
@JsonSerialize(using = JsonTimeSerializer.class) public void setAddTime(Long addTime) { this.addTime = addTime; }
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; public class JsonDateSerializer extends JsonSerializer<Long> { private SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd"); @Override public void serialize(Long datel, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException { if(datel.toString().length()<13){ datel= datel*1000L; } Date date= new Date(datel); String value = dateFormat.format(date); gen.writeString(value); } }
// Use
@JsonSerialize(using = JsonDateSerializer.class) public Long getAdd_time() { return add_time; }
边栏推荐
- Pytorch配置
- 基于QT的tensorRT加速的yolov5
- @Accessors注解作用指定前缀遵守驼峰命名
- What happens between entering the URL and displaying the page?
- Idea format code idea set shortcut key format code
- Are there any recommended term life insurance products? I want to buy a term life insurance.
- [combinatorics] number of solutions of indefinite equations (number of combinations of multiple sets R | number of non negative integer solutions of indefinite equations | number of integer solutions
- About HTTP cache control
- How do you adjust the scope of activerecord Association in rails 3- How do you scope ActiveRecord associations in Rails 3?
- docker安装mysql
猜你喜欢
函数栈帧的创建与销毁
Thunderbolt Chrome extension caused the data returned by the server JS parsing page data exception
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
【PyG】理解MessagePassing过程,GCN demo详解
Vs 2019 configuration du moteur de génération de tensorrt
迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
[error record] the parameter 'can't have a value of' null 'because of its type, but the im
Yiwen takes you to know ZigBee
Sqlserver row to column pivot
Vs Code configure virtual environment
随机推荐
MySql实战45讲【全局锁和表锁】
Kubernetes cluster log and efk architecture log scheme
Use of El tree search method
解决高并发下System.currentTimeMillis卡顿
el-tree搜索方法使用
Sous - système I2C (IV): débogage I2C
Spark on yarn资源优化思路笔记
The file marked by labelme is converted to yolov5 format
[combinatorics] number of solutions of indefinite equations (number of combinations of multiple sets R | number of non negative integer solutions of indefinite equations | number of integer solutions
Check log4j problems using stain analysis
Opengauss database development and debugging tool guide
Super easy to use logzero
迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
基于QT的tensorRT加速的yolov5
Add automatic model generation function to hade
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
VS 2019 配置tensorRT生成engine
C language beginner level - pointer explanation - paoding jieniu chapter
[C language] MD5 encryption for account password
The XML file generated by labelimg is converted to VOC format