0

I'm trying to use JodaTime (2.3) to store values returned from an API call in millis from epoch as a datetime string in SQLite3.

new DateTime(Instant.now).toString() or Instant.now().toDateTime().toString() both work as expected.

I'm having trouble with the DateTime(long) constructor, where I supply the long value.

For example:

new DateTime(1388067172).toString() gives "1970-01-17T..." (note, 17th not 1st so it is offsetting somewhat) whereas I expect it to be "2013-12-26T...".

1 Answer 1

2

My current unix-time is (was) 1388091226903. I think you have to multiply the value you get with 1000, it seems to be given in seconds since 1st Jan 1970, but you want the time given in milliseconds since 1st of Jan 1970...

1
  • of course. I used epoch converter to validate, but checking again now, it takes both milliseconds and seconds! Thanks.
    – ataulm
    Dec 26, 2013 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.