Search code examples
javajodatimesql-timestamp

java.sql.Timestamp to Joda Instant and vice versa


Is this possible? I found a few solution for converting to and from localDateTime like can be seen here

But I can't find a solution for Joda Instant...


Solution

  • You can use the epoch millis to convert:

    Timestamp ts = ....;
    Instant i = new Instant(ts.getTime());
    Timestamp ts2 = new Timestamp(i.getMillis());