Upgrade to Pro — share decks privately, control downloads, hide ads and more …

kotlinx.datetime 使ってみた

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

kotlinx.datetime 使ってみた

Avatar for Takuji Nishibayashi

Takuji Nishibayashi

July 10, 2024
Tweet

More Decks by Takuji Nishibayashi

Other Decks in Technology

Transcript

  1. 自己紹介 西林 拓志 (にしばやし たくじ ) Twitter/GitHub takuji31 Sansan 株式会社

    2024/04/01 入社 技術本部 Mobile Application グループ 6 月〜 Eight Android チーム テックリード Android (2009〜 ) Kotlin (2014〜 ) 1
  2. build.gradle.kts repositories { mavenCentral() } kotlin { sourceSets { commonMain

    { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0") } } } } 15
  3. 使い方 val now = Clock.System.now() now.epochSeconds // 1970/01/01 00:00:00からの経過秒数 now.toEpochMilliseconds()

    // 1970/01/01 00:00:00からの経過ミリ秒数 now.nanosecondsOfSecond // ナノ秒 val secondLater = now + 1.seconds// 1秒後 val sameTimeOfYesterday = now - 1.days // 昨日の同じ時間 21
  4. 使い方 val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) now.year // 2024 now.month //

    Month.JULY now.monthNumber // 7 now.date // 10 now.hour // 12 now.minute // 34 now.second // 56 25