PHP Avenger
PHP Avenger

Reputation: 1801

Jersey Restful service return date value format is changed

I was developing an API using Jersey Restful service, every thing was working fine. the returned date value was in milliseconds on client side I had a logic to convert this date before rendering its value

$dateValue = ($dateValue * 0.001);

After completing the API part I wanted to add Swagger documentation, (I am not sure if this the reason). After all the documentation I have noticed that my dates are not displayed properly. Received date value from Jersey API is as follow. (format changed).

[insertDate] => 2015-07-13T08:08:58.000+0000

here is how it is declared in DTO class

private Date insertDate;

Upvotes: 0

Views: 674

Answers (1)

Paul Samsotha
Paul Samsotha

Reputation: 209004

Swagger seems to be culprit. It configures it's own Jackson provider, and that is the same provider used for your Jersey app. I am not sure how to change this behavior. There was a question raised where the OP was trying to configure the Jackson output, but I don't know if there was ever a solution. Maybe some digging around will give a more definite answer.

As far as the output, it's standard ISO-8601 format, so you should be able to find a library or standard PHP API to handle the parsing. I don't work with PHP, but looking at this post or the duplicate, there is a DateTime that can handle the parsing.

As far as your questions in the comments about the format, looking at the wikipedia link, it appears the T is no more than a delimiter (with no "value"). It could be replaced with a space, if the parsing library permitted it. The 000+0000 is the millisecond + the UTC timezone offset

Upvotes: 1

Related Questions