Jersey (MOXy) Shortens JSON Dates

I use Jersey 1.21.1 and I get weird behavior on cancellation dates.

A simplified version of my POJO:

@XmlRootElement
public class Invoice {
    private Date invoiceDate;
    private Date invoiceDate2;
}

My resource method:

@PUT
@Consumes(MediaType.APPLICATION_JSON)
public Response putInvoice(Invoice invoice) { .. }

The JavaScript code that calls this service uses the JSON.stringifyfollowing HTTP request payload (this is what was sent according to the Chrome debugger):

{"InvoiceDate": "2015-10-27T04: 00: 00.000Z", "invoiceDate2": "2015-10-27T08: 00: 00.000Z"}

So far so good. But when I stop at the breakpoint inside putInvoiceand look at the Java dates invoice.invoiceDate and invoice.invoiceDate2, they both have the same fastTime:

1445904000000

(which is equal to October 27, 2015 12:00:00 UTC).

, /, , , UTC ISO. , - . .

+4
1

, POJO java.sql.Date, java.util.Date. ISO , java.util.Date.

java.util.Date POJO. - java.sql.Date, XmlAdaptor (. SO: jaxb unmarshal timestamp)

: , , java.sql.Date Jersey/MOXy , . , , , , , XmlAdaptor. , .

MOXy , , - , MOXy . , java.sql.Date, ? , , . (: , , - . )

+2

Source: https://habr.com/ru/post/1621491/


All Articles