[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7418":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":7,"languages":10,"totalLinesOfCode":10,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":31,"discoverSource":32},7418,"kotlinx-datetime","Kotlin\u002Fkotlinx-datetime","Kotlin","KotlinX multiplatform date\u002Ftime library","",null,2807,130,60,31,0,2,12,1,60.55,"Apache License 2.0",false,"master",[24,25,26,27],"date","datetime","kotlin","timezone","2026-06-12 04:00:33","# kotlinx-datetime\n\n[![Kotlin Alpha](https:\u002F\u002Fkotl.in\u002Fbadges\u002Falpha.svg)](https:\u002F\u002Fkotlinlang.org\u002Fdocs\u002Fcomponents-stability.html)\n[![JetBrains official project](https:\u002F\u002Fjb.gg\u002Fbadges\u002Fofficial.svg)](https:\u002F\u002Fconfluence.jetbrains.com\u002Fdisplay\u002FALL\u002FJetBrains+on+GitHub)\n[![GitHub license](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache%20License%202.0-blue.svg?style=flat)](http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0)\n[![Maven Central](https:\u002F\u002Fimg.shields.io\u002Fmaven-central\u002Fv\u002Forg.jetbrains.kotlinx\u002Fkotlinx-datetime?filter=0.8.0-rc02)](https:\u002F\u002Fsearch.maven.org\u002Fsearch?q=g:org.jetbrains.kotlinx%20AND%20a:kotlinx-datetime)\n[![Kotlin](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fkotlin-2.1.20-blue.svg?logo=kotlin)](http:\u002F\u002Fkotlinlang.org)\n[![KDoc link](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAPI_reference-KDoc-blue)](https:\u002F\u002Fkotlinlang.org\u002Fapi\u002Fkotlinx-datetime\u002F)\n[![Slack channel](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fchat-slack-blue.svg?logo=slack)](https:\u002F\u002Fkotlinlang.slack.com\u002Fmessages\u002Fkotlinx-datetime\u002F)\n[![TeamCity build](https:\u002F\u002Fimg.shields.io\u002Fteamcity\u002Fbuild\u002Fs\u002FKotlinTools_KotlinxDatetime_Build_All.svg?server=http%3A%2F%2Fteamcity.jetbrains.com)](https:\u002F\u002Fteamcity.jetbrains.com\u002FviewType.html?buildTypeId=KotlinTools_KotlinxDatetime_Build_All&guest=1)\n\nA multiplatform Kotlin library for working with date and time.\n\nSee [Using in your projects](#using-in-your-projects) for the instructions on how to set up a dependency in your project.\n\n## Design overview\n\nThere are a few guiding principles in the design of `kotlinx-datetime`. First of all, it is pragmatic and focused\non the most common problems developers face every day (pun intended) when working with dates and times. It is not\nall-encompassing and lacks some domain-specific utilities that special-purpose applications might need.\nWe chose convenience over generality, so the API surface this library provides is as minimal as possible\nto meet the use cases.\n\nThe library puts a clear boundary between the physical time of an instant and the local, time-zone-dependent\ncivil time, consisting of components such as year, month, etc that people use when talking about time.\nWe intentionally avoid entities in the library that mix both together and could be misused.\nHowever, there are convenience operations that take, for example, a physical instant and perform a calendar-based\nadjustment (such as adding a month); all such operations\nexplicitly take time-zone information as a parameter to clearly state that their result depends on the civil time zone\nrules which are subject to change at any time.\n\nThe library is based on the ISO 8601 international standard, other ways to represent dates and times are out of\nits scope. Internationalization (such as locale-specific month and day names) is out of the scope, too.\n\n## Types\n\nThe library provides a basic set of types for working with date and time:\n\n- `LocalDateTime` to represent date and time components without a reference to the particular time zone;\n- `LocalDate` to represent the components of date only;\n- `YearMonth` to represent only the year and month components;\n- `LocalTime` to represent the components of time only;\n- `TimeZone` and `FixedOffsetTimeZone` provide time zone information to convert between\n  `kotlin.time.Instant` and `LocalDateTime`;\n- `Month` and `DayOfWeek` enums;\n- `DateTimePeriod` to represent a difference between two instants decomposed into date and time units;\n- `DatePeriod` is a subclass of `DateTimePeriod` with zero time components,\nit represents a difference between two LocalDate values decomposed into date units.\n- `DateTimeUnit` provides a set of predefined date and time units to use in arithmetic operations\n  on `kotlin.time.Instant` and `LocalDate`.\n- `UtcOffset` represents the amount of time the local datetime at a particular time zone differs from the datetime at UTC.\n\n### Type use-cases\n\nHere is some basic advice on how to choose which of the date-carrying types to use in what cases:\n\n- Use `kotlin.time.Instant` to represent a timestamp of the event that had already happened in the past\n  (like a timestamp of a log entry) or will definitely happen in a well-defined instant of time in the future\n  not far away from now\n  (like an order confirmation deadline in 1 hour from now).\n- Use `LocalDateTime` to represent a time of the event that is scheduled to happen in the far future at a certain\n  local time (like a scheduled meeting in a few months from now). You'll have to keep track of the `TimeZone` of\n  the scheduled event separately. Try to avoid converting future events to `Instant` in advance, because time zone\n  rules might change unexpectedly in the future. In this [blog post](https:\u002F\u002Fcodeblog.jonskeet.uk\u002F2019\u002F03\u002F27\u002Fstoring-utc-is-not-a-silver-bullet\u002F), you can read more about why it's not always\n  a good idea to use `Instant` everywhere.\n\n  Also use `LocalDateTime` to decode an `Instant` to its local datetime components for display and UIs.\n\n- Use `LocalDate` to represent the date of an event that does not have a specific time associated with it (like a birth date).\n\n- Use `YearMonth` to represent the year and month of an event that does not have a specific day associated with it\n  or has a day-of-month that is inferred from the context (like a credit card expiration date).\n\n- Use `LocalTime` to represent the time of an event that does not have a specific date associated with it.\n\n## Operations\n\nWith the above types, you can get the following operations done.\n\n### Converting an instant to local date and time components\n\nAn `Instant` is just a counter of high-resolution time intervals since the beginning of the time scale.\nTo get human readable components from an `Instant` value, you need to convert it to the `LocalDateTime`\ntype that represents date and time components without a reference to the particular time zone.\n\nThe `TimeZone` type provides the rules to convert instants from and to datetime components.\n\n```kotlin\nval currentMoment: Instant = Clock.System.now()\nval datetimeInUtc: LocalDateTime = currentMoment.toLocalDateTime(TimeZone.UTC)\nval datetimeInSystemZone: LocalDateTime = currentMoment.toLocalDateTime(TimeZone.currentSystemDefault())\n```\n\nA `LocalDateTime` instance exposes familiar components of the Gregorian calendar:\n`year`, `month`, `day`, `hour`, and so on up to `nanosecond`.\nThe property `dayOfWeek` shows what weekday that date is,\nand `dayOfYear` shows the day number since the beginning of a year.\n\n\nAdditional time zones can be acquired by their string identifier with the `TimeZone.of(id: String)` function.\n```kotlin\nval tzBerlin = TimeZone.of(\"Europe\u002FBerlin\")\nval datetimeInBerlin = currentMoment.toLocalDateTime(tzBerlin)\n```\n\nA `LocalDateTime` instance can be constructed from individual components:\n\n```kotlin\nval kotlinReleaseDateTime = LocalDateTime(2016, 2, 15, 16, 57, 0, 0)\n```\n\nAn instant can be obtained from `LocalDateTime` by interpreting it as a time moment\nin a particular `TimeZone`:\n\n```kotlin\nval kotlinReleaseInstant = kotlinReleaseDateTime.toInstant(TimeZone.of(\"UTC+3\"))\n```\n\n### Getting local date components\n\nA `LocalDate` represents a local date without time. You can obtain one from an `Instant`\nby converting it to `LocalDateTime` and taking its `date` property.\n\n```kotlin\nval now: Instant = Clock.System.now()\nval today: LocalDate = now.toLocalDateTime(TimeZone.currentSystemDefault()).date\n\u002F\u002F or shorter\nval today: LocalDate = Clock.System.todayIn(TimeZone.currentSystemDefault())\n```\nNote, that today's date really depends on the time zone in which you're observing the current moment.\n\n`LocalDate` can be constructed from three components, year, month, and day:\n```kotlin\nval knownDate = LocalDate(2020, 2, 21)\n```\n\n### Getting year and month components\n\nA `YearMonth` represents a year and month without a day. You can obtain one from a `LocalDate`\nby taking its `yearMonth` property.\n\n```kotlin\nval day = LocalDate(2020, 2, 21)\nval yearMonth: YearMonth = day.yearMonth\n```\n\n### Getting local time components\n\nA `LocalTime` represents local time without a date. You can obtain one from an `Instant`\nby converting it to `LocalDateTime` and taking its `time` property.\n\n```kotlin\nval now: Instant = Clock.System.now()\nval thisTime: LocalTime = now.toLocalDateTime(TimeZone.currentSystemDefault()).time\n```\n\nA `LocalTime` can be constructed from four components, hour, minute, second, and nanosecond:\n```kotlin\nval knownTime = LocalTime(hour = 23, minute = 59, second = 12)\nval timeWithNanos = LocalTime(hour = 23, minute = 59, second = 12, nanosecond = 999)\nval hourMinute = LocalTime(hour = 12, minute = 13)\n```\n\n### Converting instant and local datetime to and from the ISO 8601 string\n\n`Instant`, `LocalDateTime`, `LocalDate` and `LocalTime` provide shortcuts for\nparsing and formatting them using the extended ISO 8601 format.\nThe `toString()` function is used to convert the value to a string in that format, and\nthe `parse` function in companion object is used to parse a string representation back.\n\n```kotlin\nval localDateTime = LocalDateTime(2025, 3, 21, 12, 27, 35, 124365453)\nlocalDateTime.toString()  \u002F\u002F 2025-03-21T12:27:35.124365453\nval sameLocalDateTime = LocalDateTime.parse(\"2025-03-21T12:27:35.124365453\")\n```\n\n`LocalDate` uses a format with just year, month, and date components, e.g. `2010-06-01`.\n\n`LocalTime` uses a format with just hour, minute, second, and (if non-zero) nanosecond components, e.g. `12:01:03`.\n\n```kotlin\nLocalDate.parse(\"2010-06-01\")\nLocalTime.parse(\"12:01:03\")\nLocalTime.parse(\"12:00:03.999\")\nLocalTime.parse(\"12:0:03.999\") \u002F\u002F fails with an IllegalArgumentException\n```\n\n### Working with other string formats\n\nWhen some data needs to be formatted in some format other than ISO 8601, one\ncan define their own format or use some of the predefined ones:\n\n```kotlin\n\u002F\u002F import kotlinx.datetime.format.*\n\nval dateFormat = LocalDate.Format {\n    monthNumber(padding = Padding.SPACE)\n    char('\u002F')\n    day()\n    char(' ')\n    year()\n}\n\nval date = dateFormat.parse(\"12\u002F24 2023\")\nprintln(date.format(LocalDate.Formats.ISO_BASIC)) \u002F\u002F \"20231224\"\n```\n\n#### Using Unicode format strings (like `yyyy-MM-dd`)\n\nGiven a constant format string like the ones used by Java's\n[DateTimeFormatter.ofPattern](https:\u002F\u002Fdocs.oracle.com\u002Fjavase\u002F8\u002Fdocs\u002Fapi\u002Fjava\u002Ftime\u002Fformat\u002FDateTimeFormatter.html) can be\nconverted to Kotlin code using the following invocation:\n\n```kotlin\n\u002F\u002F import kotlinx.datetime.format.*\n\nprintln(DateTimeFormat.formatAsKotlinBuilderDsl(DateTimeComponents.Format {\n    byUnicodePattern(\"uuuu-MM-dd'T'HH:mm:ss[.SSS]Z\")\n}))\n\n\u002F\u002F will print:\n\u002F*\ndate(LocalDate.Formats.ISO)\nchar('T')\nhour()\nchar(':')\nminute()\nchar(':')\nsecond()\nalternativeParsing({\n}) {\n    char('.')\n    secondFraction(3)\n}\noffset(UtcOffset.Formats.FOUR_DIGITS)\n *\u002F\n```\n\nWhen your format string is not constant, with the `FormatStringsInDatetimeFormats` opt-in,\nyou can use the format without converting it to Kotlin code beforehand:\n\n```kotlin\nval formatPattern = \"yyyy-MM-dd'T'HH:mm:ss[.SSS]\"\n\n@OptIn(FormatStringsInDatetimeFormats::class)\nval dateTimeFormat = LocalDateTime.Format {\n    byUnicodePattern(formatPattern)\n}\n\ndateTimeFormat.parse(\"2023-12-24T23:59:59\")\n```\n\n### Parsing and formatting partial, compound or out-of-bounds data\n\nSometimes, the required string format doesn't fully correspond to any of the\nclasses `kotlinx-datetime` provides. In these cases, `DateTimeComponents`, a\ncollection of all datetime fields, can be used instead.\n\n```kotlin\n\u002F\u002F import kotlinx.datetime.format.*\n\nval monthDay = DateTimeComponents.Format { monthNumber(); char('\u002F'); day() }\n    .parse(\"12\u002F25\")\nprintln(monthDay.day) \u002F\u002F 25\nprintln(monthDay.monthNumber) \u002F\u002F 12\n\nval dateTimeOffset = DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET\n    .parse(\"2023-01-07T23:16:15.53+02:00\")\nprintln(dateTimeOffset.toUtcOffset()) \u002F\u002F +02:00\nprintln(dateTimeOffset.toLocalDateTime()) \u002F\u002F 2023-01-07T23:16:15.53\n```\n\nOccasionally, one can encounter strings where the values are slightly off:\nfor example, `23:59:60`, where `60` is an invalid value for the second.\n`DateTimeComponents` allows parsing such values as well and then mutating them\nbefore conversion.\n\n```kotlin\nval time = DateTimeComponents.Format { time(LocalTime.Formats.ISO) }\n    .parse(\"23:59:60\").apply {\n        if (second == 60) second = 59\n    }.toLocalTime()\nprintln(time) \u002F\u002F 23:59:59\n```\n\nBecause `DateTimeComponents` is provided specifically for parsing and\nformatting, there is no way to construct it normally. If one needs to format\npartial, complex or out-of-bounds data, the `format` function allows building\n`DateTimeComponents` specifically for formatting it:\n\n```kotlin\nDateTimeComponents.Formats.RFC_1123.format {\n    \u002F\u002F the receiver of this lambda is DateTimeComponents\n    setDate(LocalDate(2023, 1, 7))\n    hour = 23\n    minute = 59\n    second = 60\n    setOffset(UtcOffset(hours = 2))\n} \u002F\u002F Sat, 7 Jan 2023 23:59:60 +0200\n```\n\n### Instant arithmetic\n\nThe `Instant` arithmetic operations that don't involve the calendar are available purely in the standard library\nand do not require using `kotlinx-datetime`:\n\n```kotlin\nval now = Clock.System.now()\nval instantInThePast: Instant = Instant.parse(\"2020-01-01T00:00:00Z\")\nval durationSinceThen: Duration = now - instantInThePast\nval equidistantInstantInTheFuture: Instant = now + durationSinceThen\n```\n\nTo get the calendar difference between two instants you can use the `Instant.periodUntil(Instant, TimeZone)` function.\n\n```kotlin\nval period: DateTimePeriod = instantInThePast.periodUntil(Clock.System.now(), TimeZone.UTC)\n```\n\nA `DateTimePeriod` represents a difference between two particular moments as a sum of calendar components,\nlike \"2 years, 3 months, 10 days, and 22 hours\".\n\nThe difference can be calculated as an integer amount of specified date or time units:\n\n```kotlin\nval diffInMonths = instantInThePast.until(Clock.System.now(), DateTimeUnit.MONTH, TimeZone.UTC)\n```\nThere are also shortcuts `yearsUntil(...)`, `monthsUntil(...)`, and `daysUntil(...)`.\n\nA particular amount of datetime units or a datetime period can be added to an `Instant` with the `plus` function:\n\n```kotlin\nval now = Clock.System.now()\nval systemTZ = TimeZone.currentSystemDefault()\nval tomorrow = now.plus(2, DateTimeUnit.DAY, systemTZ)\nval threeYearsAndAMonthLater = now.plus(DateTimePeriod(years = 3, months = 1), systemTZ)\n```\n\nNote that `plus` and `...until` operations require a `TimeZone` as a parameter because the calendar interval between\ntwo particular instants can be different when calculated in different time zones.\n\n### Date arithmetic\n\nSimilar operations with date units are provided for `LocalDate` type:\n\n- `LocalDate.plus(number, DateTimeUnit.DateBased)`\n- `LocalDate.plus(DatePeriod)`\n- `LocalDate.until(LocalDate, DateTimeUnit.DateBased)` and the shortcuts `yearsUntil`, `monthUntil`, `daysUntil`\n- `LocalDate.periodUntil(LocalDate): DatePeriod` and `LocalDate.minus(LocalDate): DatePeriod`\n\nNotice that, instead of the general `DateTimeUnit` and `DateTimePeriod` types, we're using their subtypes\n`DateTimeUnit.DateBased` and `DatePeriod` respectively. This allows preventing the situations when\ntime components are being added to a date at compile time.\n\n### Date + time arithmetic\n\nArithmetic on `LocalDateTime` is intentionally omitted. The reason for this is that the presence of daylight saving time\ntransitions (changing from standard time to daylight saving time and back) causes `LocalDateTime` arithmetic to be\nill-defined. For example, consider time gaps (or, as [`dst` tag wiki on Stack Overflow](https:\u002F\u002Fstackoverflow.com\u002Ftags\u002Fdst\u002Finfo)\ncalls them, \"spring forward\" transitions), that is, ranges of date + time combinations that never occur in a given\ntime zone due to clocks moving forward. If we allowed `LocalDateTime` arithmetic that ignored time zones, then it\ncould result in `LocalDateTime` instances that are inside a time gap and are invalid in the implied time zone.\n\nTherefore, the recommended way to use a `LocalDateTime` is to treat it as a representation of an `Instant`,\nperform all the required arithmetic on `Instant` values, and only convert to `LocalDateTime` when a human-readable\nrepresentation is needed.\n\n```kotlin\nval timeZone = TimeZone.of(\"Europe\u002FBerlin\")\nval localDateTime = LocalDateTime.parse(\"2021-03-27T02:16:20\")\nval instant = localDateTime.toInstant(timeZone)\n\nval instantOneDayLater = instant.plus(1, DateTimeUnit.DAY, timeZone)\nval localDateTimeOneDayLater = instantOneDayLater.toLocalDateTime(timeZone)\n\u002F\u002F 2021-03-28T03:16:20, as 02:16:20 that day is in a time gap\n\nval instantTwoDaysLater = instant.plus(2, DateTimeUnit.DAY, timeZone)\nval localDateTimeTwoDaysLater = instantTwoDaysLater.toLocalDateTime(timeZone)\n\u002F\u002F 2021-03-29T02:16:20\n```\n\n## Implementation\n\nThe implementation of datetime types, such as `LocalDateTime`, `TimeZone`, and so on, relies on:\n\n- in JVM: [`java.time`](https:\u002F\u002Fdocs.oracle.com\u002Fjavase\u002F8\u002Fdocs\u002Fapi\u002Fjava\u002Ftime\u002Fpackage-summary.html) API;\n- the other platforms: based on the [ThreeTen backport project](https:\u002F\u002Fwww.threeten.org\u002Fthreetenbp\u002F)\n  - time zone support on JS and Wasm\u002FJS is provided by the [`js-joda`](https:\u002F\u002Fjs-joda.github.io\u002Fjs-joda\u002F) library.\n\n## Known\u002Fopen issues, work TBD\n\n- [ ] Flexible locale-neutral parsing and formatting facilities are needed to support various datetime interchange\n  formats that are used in practice (in particular, various RFCs).\n\n## Using in your projects\n\n> Note that the library is experimental, and the API is subject to change.\n\nThe library is published to Maven Central.\n\nThe library is compatible with the Kotlin Standard Library not lower than `2.1.20`.\n\nIf you target Android devices running **below API 26**, you need to use Android Gradle plugin 4.0 or newer\nand enable [core library desugaring](https:\u002F\u002Fdeveloper.android.com\u002Fstudio\u002Fwrite\u002Fjava8-support#library-desugaring).\n\n### Deprecation of `Instant`\n\n`kotlinx-datetime` versions earlier than `0.7.0` used to provide `kotlinx.datetime.Instant`\nand `kotlinx.datetime.Clock`.\nThe Kotlin standard library started including its own, identical `kotlin.time.Instant` and `kotlin.time.Clock`,\nas it became evident that `Instant` was also useful outside the datetime contexts.\n\nHere is the recommended procedure for migrating from `kotlinx-datetime` version `0.6.x` or earlier to `0.7.x`:\n\n* First, simply try upgrading to `0.7.1`.\n  If your project has a dependency on `kotlinx-datetime`, but doesn't have dependencies on other libraries that are\n  *themselves* reliant on an older `kotlinx-datetime`, you are good to go: the code should compile and run.\n  This applies both to applications and to libraries!\n* If your project depends on other libraries that themselves use an older version of `kotlinx-datetime`,\n  then your code may fail at runtime with a `ClassNotFoundException`\n  for `kotlinx.datetime.Instant` or `kotlinx.datetime.Clock`, or maybe even fail to compile.\n  In that case, please check if the affected libraries you have as dependencies have already published a new release\n  adapted to use `Instant` and `Clock` from `kotlin.time`.\n* If you use `kotlinx-serialization` to serialize the `Instant` type, update that dependency to use\n  [1.9.0](https:\u002F\u002Fgithub.com\u002FKotlin\u002Fkotlinx.serialization\u002Freleases\u002Ftag\u002Fv1.9.0) or a newer version.\n* If all else fails, use the *compatibility release* of `kotlinx-datetime`.\n  Instead of the version `0.7.1`, use `0.7.1-0.6.x-compat`.\n  This artifact still contains `kotlinx.datetime.Instant` and `kotlinx.datetime.Clock`,\n  ensuring that third-party libraries reliant on them can still be used.\n  This artifact is less straightforward to use than `0.7.1`, so only resort to it when libraries you don't control\n  require that the removed classes still exist.\n\nTips for fixing compilation errors:\n\n* If you encounter resolution ambiguity errors for `Instant` or `Clock`,\n  see if you have `import kotlin.time.*` along with `import kotlinx.datetime.*`.\n  Since both libraries have a `Clock` and an `Instant`, you have to manually add\n  `import kotlin.time.Instant` and\u002For `import kotlin.time.Clock` explicitly.\n* When using the compatibility release of `kotlinx-datetime`, you may encounter errors like\n  \"required `kotlinx.datetime.Instant`, found `kotlin.time.Instant`\" or vice versa.\n  - First, please check if you have imported a `kotlinx.datetime` class when a `kotlin.time` class would work.\n    The final goal is getting rid of `kotlinx.datetime.Instant`, so limit its usage as much as possible!\n  - If you have no choice but to use an `Instant` or `Clock` from `kotlinx-datetime` (for example, because a third-party\n    library accepts a `kotlinx.datetime.Instant` as a parameter or returns it as a function result),\n    you can use the compatibility functions:\n    * `kotlin.time.Instant.toDeprecatedInstant(): kotlinx.datetime.Instant`\n    * `kotlin.time.Clock.toDeprecatedClock(): kotlinx.datetime.Clock`\n    * `kotlinx.datetime.Instant.toStdlibInstant(): kotlin.time.Instant`\n    * `kotlinx.datetime.Clock.toStdlibClock(): kotlin.time.Clock`\n\n> Compatibility releases will be published for all `0.7.x` versions of `kotlinx-datetime`, but not longer.\n\n### Gradle\n\n- Add the Maven Central repository if it is not already there:\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n```\n\n- In multiplatform projects, add a dependency to the dependencies of the `commonMain` source set\n```kotlin\nkotlin {\n    sourceSets {\n        commonMain {\n             dependencies {\n                 implementation(\"org.jetbrains.kotlinx:kotlinx-datetime:0.8.0-rc02\")\n             }\n        }\n    }\n}\n```\n\n- To use the library in a single-platform project, add a dependency to the dependencies block.\n\n```groovy\ndependencies {\n    implementation(\"org.jetbrains.kotlinx:kotlinx-datetime:0.8.0-rc02\")\n}\n```\n\n#### Note about time zones in JS\n\nBy default, there's only one time zone available in Kotlin\u002FJS: the `SYSTEM` time zone with a fixed offset.\n\nIf you want to use all time zones in the Kotlin\u002FJS platform, you need to add the following npm dependency\n(replace X.X.X below with the latest version [from here](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@js-joda\u002Ftimezone?activeTab=versions)):\n\n```kotlin\nkotlin {\n    sourceSets {\n        val jsMain by getting {\n            dependencies {\n                implementation(npm(\"@js-joda\u002Ftimezone\", \"X.X.X\"))\n            }\n        }\n    }\n}\n```\n\nand after that add the following initialization code to your project:\n\n```kotlin\n@JsModule(\"@js-joda\u002Ftimezone\")\n@JsNonModule\nexternal object JsJodaTimeZoneModule\n\n@OptIn(ExperimentalJsExport::class)\n@JsExport\nval jsJodaTz = JsJodaTimeZoneModule\n```\n\nThis code can be placed in any file in the Kotlin\u002FJS source set.\n\n#### Note about time zones in Wasm\u002FJS\n\nWasm\u002FJS uses the same time zone support as JS, so almost the same instructions apply.\n\nIn your Gradle build script, add the following dependency\n(replace X.X.X below with the latest version [from here](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@js-joda\u002Ftimezone?activeTab=versions)):\n\n```kotlin\nkotlin {\n    sourceSets {\n        val wasmJsMain by getting {\n            dependencies {\n                implementation(npm(\"@js-joda\u002Ftimezone\", \"X.X.X\"))\n            }\n        }\n    }\n}\n```\n\nand after that add the following initialization code in your project:\n\n```kotlin\n@JsModule(\"@js-joda\u002Ftimezone\")\nexternal object JsJodaTimeZoneModule\n\nprivate val jsJodaTz = JsJodaTimeZoneModule\n```\n\n#### Note about time zones in Wasm\u002FWASI\n\nBy default, there's only one time zone available in Kotlin\u002FWasm WASI: the `UTC` time zone with a fixed offset.\n\nIf you want to use all time zones in Kotlin\u002FWasm WASI platform, you need to add the following dependency:\n\n```kotlin\nkotlin {\n    sourceSets {\n        val wasmWasiMain by getting {\n            dependencies {\n                implementation(\"kotlinx-datetime-zoneinfo\", \"2026b-spi.0.8.0-rc02\")\n            }\n        }\n    }\n}\n```\n\n### Maven\n\nAdd a dependency to the `\u003Cdependencies>` element. Note that you need to use the platform-specific `-jvm` artifact in Maven.\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>org.jetbrains.kotlinx\u003C\u002FgroupId>\n    \u003CartifactId>kotlinx-datetime-jvm\u003C\u002FartifactId>\n    \u003Cversion>0.8.0-rc02\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n## Building\n\nThe project requires JDK 8 to build classes and to run tests.\nGradle will try to find it among the installed JDKs or [download](https:\u002F\u002Fdocs.gradle.org\u002Fcurrent\u002Fuserguide\u002Ftoolchains.html#sec:provisioning) it automatically if it couldn't be found.\nThe path to JDK 8 can be additionally specified with the environment variable `JDK_8`.\nFor local builds, you can use a later version of JDK if you don't have that\nversion installed. Specify the version of this JDK with the `java.mainToolchainVersion` Gradle property.\n\nAfter that, the project can be opened in IDEA and built with Gradle.\n\nFor building and running benchmarks, see [README.md](benchmarks\u002FREADME.md)\n","kotlinx-datetime 是一个多平台的 Kotlin 日期\u002F时间处理库。它提供了如 LocalDateTime、LocalDate 和 YearMonth 等基本类型，用于表示无时区依赖的日期和时间组件，以及基于 ISO 8601 标准的时间操作。该库的设计注重实用性和易用性，避免了容易导致混淆的时间与时区混合实体，并且所有涉及时区转换的操作都明确需要提供时区信息作为参数。适用于需要跨平台一致性的日期时间处理场景，尤其是那些希望减少因时区差异引起问题的应用程序开发中。","2026-06-11 03:12:14","top_language"]