当前位置:网站首页>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;
}边栏推荐
- Find the storage address of the elements in the two-dimensional array
- [algebraic structure] group (definition of group | basic properties of group | proof method of group | commutative group)
- C # general interface call
- VS 2019安装及配置opencv
- 一文带你了解 ZigBee
- How to implement append in tensor
- 45 lectures on MySQL [index]
- I2C subsystem (II): I3C spec
- MySql实战45讲【全局锁和表锁】
- 复选框的使用:全选,全不选,选一部分
猜你喜欢

Opengauss database development and debugging tool guide

Gavin teacher's perception of transformer live class - rasa project's actual banking financial BOT Intelligent Business Dialogue robot architecture, process and phenomenon decryption through rasa inte

Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)

Kubernetes family container housekeeper pod online Q & A?

Pytest (6) -fixture (Firmware)
![[Chongqing Guangdong education] cultural and natural heritage reference materials of China University of Geosciences (Wuhan)](/img/19/815e7cba81f6eb52db5ef0db556dfd.jpg)
[Chongqing Guangdong education] cultural and natural heritage reference materials of China University of Geosciences (Wuhan)

Add automatic model generation function to hade

3D drawing example

Force deduction ----- the minimum path cost in the grid

VS 2019 配置tensorRT生成engine
随机推荐
L'index des paramètres d'erreur est sorti de la plage pour les requêtes floues (1 > Nombre de paramètres, qui est 0)
[combinatorics] Application of exponential generating function (multiple set arrangement problem | different balls in different boxes | derivation of exponential generating function of odd / even sequ
C # general interface call
你真的懂继电器吗?
Force freeing memory in PHP
模型转换onnx2engine
Practice of traffic recording and playback in vivo
ComponentScan和ComponentScans的区别
MySql实战45讲【事务隔离】
The base value is too large (the error is marked as "08") [duplicate] - value too great for base (error token is'08') [duplicate]
Vs Code configure virtual environment
Check log4j problems using stain analysis
Do you really understand relays?
Three. JS local environment setup
Vs 2019 configuration du moteur de génération de tensorrt
Change cell color in Excel using C - cell color changing in Excel using C
PHP constructor with parameters - PHP constructor with a parameter
Thunderbolt Chrome extension caused the data returned by the server JS parsing page data exception
MySql实战45讲【索引】
On the adjacency matrix and adjacency table of graph storage