[ 
https://issues.apache.org/jira/browse/JOHNZON-294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16990636#comment-16990636
 ] 

Stephen Kay commented on JOHNZON-294:
-------------------------------------

Well you may close this ticket - this was a confusion with uppercase 
attributes. 

This is the full story :

 

@XmlRootElement(name = "MUTATION")
public class MutationDate {
 @XmlElement(name = "DATE", type = String.class)
 @XmlJavaTypeAdapter(Adapter2.class)
 @JsonbDateFormat("yyyy-MM-dd HH:mm:ss")
 private Date date;

public Date getDATE() \{return date;}
public void setDATE(Date date) \{this.date = date;}

}

please note uppercase attributes and XML annotations / from an external 
provider, heavy usage and now migrating from Jackson to Johnzon.

 

Now

String json = "\{\"date\":\"2019-12-02 11:04:01\"}";

=> returning a date null

String json = "\{\"DATE\":\"2019-12-02 11:04:01\"}";

=> throws exception

javax.json.bind.JsonbException: Text '2019-12-02 11:04:01' could not be parsed 
at index 10

 

Solution adding :

@JsonbProperty("date")

works as a charm with

String json = "\{\"date\":\"2019-12-02 11:04:01\"}";

 

Very best Regards / StackOverflow ticket deleted.

> @JsonbDateFormat crashes 
> -------------------------
>
>                 Key: JOHNZON-294
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-294
>             Project: Johnzon
>          Issue Type: Bug
>    Affects Versions: 1.1.12, 1.1.13, 1.2.1
>            Reporter: Stephen Kay
>            Priority: Critical
>
> [https://stackoverflow.com/questions/59225547/jsonbdateformat-support-with-johnzon]
> @JsonbDateFormat raises an exception.
> In v1.2.2, If the attribute is transient, the date format input isn't 
> rekonized / seems that the JSONB annotation isn't implemented correctly.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to