package com.hashnot.csv.sage.convert;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;

import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;

/**
 * @author Rafał Krupiński
 */
public class LocalDateDeserializer extends JsonDeserializer<LocalDate> {
    @Override
    public LocalDate deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
        try {
            return SageDate.formatter.parse(jsonParser.getText(), LocalDate::from);
        } catch (DateTimeParseException e) {
            throw new InvalidFormatException(jsonParser, "Error while parsing date", null, LocalDate.class);
        }
    }
}

@@ -82,67 +82,8 @@
 er;%0A
-import com.fasterxml.jackson.core.JsonProcessingException;%0A
 impo
@@ -199,74 +199,8 @@
 zer;
-%0Aimport com.fasterxml.jackson.databind.exc.InvalidFormatException;
 %0A%0Aim
@@ -256,56 +256,8 @@
 ate;
-%0Aimport java.time.format.DateTimeParseException;
 %0A%0A/*
@@ -501,33 +501,8 @@
 tion
-, JsonProcessingException
  %7B%0A 
@@ -512,261 +512,161 @@
     
+S
 tr
-y %7B%0A            return SageDate.formatter.parse(jsonParser.getText(), LocalDate::from);%0A        %7D catch (DateTimeParseException e) %7B%0A            throw new InvalidFormatException(jsonParser, %22Error while parsing date%22, null, LocalDate.class);%0A        %7D
+ing text = jsonParser.getText();%0A        if (text.isEmpty())%0A            return null;%0A%0A        return SageDate.formatter.parse(text, LocalDate::from);
 %0A   

Fix LocalDateDeserializer empty string handling and error reporting