Open1

【Kotlin】OffsetDateTimeでミリ秒まで出力

ふじしろふじしろ
    val time = LocalDateTime.now()
    val time1 = time.atOffset(ZoneOffset.of("+09:00")).truncatedTo(ChronoUnit.MILLIS)
    val time2 = time.atOffset(ZoneOffset.UTC).truncatedTo(ChronoUnit.MILLIS)
    val time3 = time.atOffset(ZoneOffset.of("+09:00")).truncatedTo(ChronoUnit.MILLIS).withOffsetSameInstant(ZoneOffset.UTC)

    println(time)
    println(time1)
    println(time2)
    println(time3)