-1

I am consuming an API that produces dates as Epoch timestamps but in string format:

{ "date":"1499762012700"}

Is there any way of getting this to go into a pojo as a Date object without writing some sort of custom serializer etc?

This works fine if the timestamp is a number but unfortunately this is the way it is given.

Alex
  • 587
  • 11
  • 31
  • Refer https://stackoverflow.com/questions/4216745/java-string-to-date-conversion – Sanjay Singh Jul 10 '17 at 16:10
  • Jackson can parse quoted timestamps (and any number). This `123` or this `"123"` are the same for Jackson when parsing into a Date/number in Java. What error message are you getting ? What's the configuration of your `ObjectMapper` ? – Manos Nikolaidis Jul 10 '17 at 16:16
  • Poor question. Give exact technical details. And search Stack Overflow before posting. Explain how none of [the other 1,210 Questions and Answers](https://stackoverflow.com/search?q=Jackson+date) do not address your issue. – Basil Bourque Jul 10 '17 at 16:55
  • I have seen many questions regarding the standard format such as ddMMyyyy etc, however I have not seen a numerical timestamp stored as a string before and I could not find any questions related to this. – Alex Jul 11 '17 at 08:37

1 Answers1

0

Is it a 9 digit timestamp? It would be helpful to have an actual example. If its unix time and do you want a java Date or a JODA object. I'd go with JODA

If its a unix 10 digit time stamp look here Java: Date from unix timestamp or

Shawn S
  • 49
  • 5