-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
Hi
thank you for share a awesome library.
I am using version 2.6.7.
Here is failed test which shows that @JsonFormat
is ignored pattern
attribute.
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import java.sql.Date;
import static org.junit.Assert.assertEquals;
public class JsonFormatTest {
public class Person {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.mm.dd")
public Date dateOfBirth;
}
@Test
public void JsonFormatPatternTest() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
Person i = new Person();
i.dateOfBirth = Date.valueOf("1980-04-14");
assertEquals("{\"dateOfBirth\":\"1980.04.14\"}", objectMapper.writeValueAsString(i));
}
}
And the results of running the test:
org.junit.ComparisonFailure:
Expected :{"dateOfBirth":"1980.04.14"}
Actual :{"dateOfBirth":"1980-04-14"}
I don't know exactly the reason.
But I have a doubt in a line of code.
https://github.com/FasterXML/jackson-databind/blob/2.6/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlDateSerializer.java#L36
Which method ignored the customFormat
param.
Thank you.
Metadata
Metadata
Assignees
Labels
No labels