微调
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.njcn.influx.utils;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年07月24日 13:33
|
||||
*/
|
||||
@Component
|
||||
public class InstantDateDeserializer extends StdDeserializer<Instant> {
|
||||
|
||||
|
||||
public InstantDateDeserializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
|
||||
protected InstantDateDeserializer(Class<?> vc) {
|
||||
super(vc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Instant deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
String text = p.getValueAsString();
|
||||
return InstantUtil.dateToInstant(DateUtil.parse(text,DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user