0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Unixtime(13桁)からorg.joda.time.DateTimeへの変換

Last updated at Posted at 2020-03-08

Unixtimeをorg.joda.time.DateTime変換してDBに突っ込みたかった時の変換メモ

val unixtime = 1583474375000

// String -> Date(Fri Mar 06 05:59:35 JST 2020)
val myDate = Date.from(Instant.ofEpochMilli(unixTime))

// Date -> DateTime(2020-03-06T05:59:35.000+09:00)
val myDateTime = DateTime(myDate)

※10桁の場合はformatにofEpochSecondを使う。

val myDate = Date.from(Instant.ofEpochSecond(unixTime))
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?