![JAR search and dependency download from the Maven repository](/logo.png)
dsl_json.java.sql.DateDslJsonConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dsl-json-java8 Show documentation
Show all versions of dsl-json-java8 Show documentation
DSL Platform compatible Java JSON library (https://dsl-platform.com)
package dsl_json.java.sql;
import com.dslplatform.json.*;
import java.io.IOException;
import java.sql.Date;
public class DateDslJsonConverter implements Configuration {
@Override
public void configure(DslJson json) {
json.registerReader(java.sql.Date.class, new JsonReader.ReadObject() {
@Nullable
@Override
public Date read(JsonReader reader) throws IOException {
return reader.wasNull() ? null : java.sql.Date.valueOf(JavaTimeConverter.deserializeLocalDate(reader));
}
});
json.registerWriter(java.sql.Date.class, new JsonWriter.WriteObject() {
@Override
public void write(JsonWriter writer, @Nullable java.sql.Date value) {
if (value == null) writer.writeNull();
else JavaTimeConverter.serialize(value.toLocalDate(), writer);
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy