invoices

Invoiced API time milliseconds issue


I use invoiced API

https://invoiced.com/docs/guides/subscription-billing

and I got records like

"renewed_last": 1493732122,
"renews_next": 1496410522,
"start_date": 1493732122,

What those magic numbers mean? I thought this is milliseconds from 1970, but it's not true. They can render data properly on their site, but I can't get date for me app. How to get date from those magic numbers?


Solution

  • According to the api docs all dates are in unixtimestamp https://en.wikipedia.org/wiki/Unix_time

    It is timestamp in seconds from Jan 1 1970, Java calculates time in millisecond

    So the solution is

    new Date(unixTimestamp * 1000L);