
io.github.dft.woocommerce.model.common.DateDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of woocommerce Show documentation
Show all versions of woocommerce Show documentation
woocommerce API using JDK 11
package io.github.dft.woocommerce.model.common;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class DateDeserializer extends JsonDeserializer {
@Override
public LocalDateTime deserialize(JsonParser jp, DeserializationContext ctxt) {
try {
String timestamp = jp.getText().trim();
DateTimeFormatter isoFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
return LocalDateTime.parse(timestamp, isoFormatter);
} catch (Exception exception) {
System.out.println(exception.getMessage());
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy