kotlinx-datetime | KotlinX multiplatform date/time library
kandi X-RAY | kotlinx-datetime Summary
kandi X-RAY | kotlinx-datetime Summary
There are a few guiding principles in the design of kotlinx-datetime. First of all, it is pragmatic, focused on the most common problems developers face every day (pun intended) when working with dates and times. It is not all-encompassing and lacks some domain-specific utilities that special-purpose applications might need. We chose convenience over generality, so the API surface this library provides is as minimal as possible to meet the use-cases. The library puts a clear boundary between physical time of an instant and a local, time-zone dependent civil time, consisting of components such as year, month, etc that people use when talking about time. We intentionally avoid entities in the library that mix both together and could be misused. However, there are convenience operations that take, for example, a physical instant and perform a calendar-based adjustment (such as adding a month); all such operation explicitly take a time-zone information as parameter to clearly state that their result depends on the civil time-zone rules which are subject to change at any time. The library is based on the ISO 8601 international standard, other ways to represent dates and times are out of its scope. Internationalization (such as locale-specific month and day names) is out the scope, too.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of kotlinx-datetime
kotlinx-datetime Key Features
kotlinx-datetime Examples and Code Snippets
Community Discussions
Trending Discussions on kotlinx-datetime
QUESTION
I'm converting some code from using Java 8's LocalDatetime
to using the version from kotlinx-datetime
and I can't find any formatting methods. Specifically, I'm replacing a FormatStyle.MEDIUM
. Do they not exist and I need to write the formatting?
This is for an Android app. Is there are there Android specific libraries I can use? Or can I do this with pre-Java 8 methods to maintain support for older versions of Android?
Edit (my solution based on the answer from Arvind):
...ANSWER
Answered 2021-Nov-06 at 12:20As per the documentation, in a JVM, the implementation of date/time types, such as Instant
, LocalDateTime
, TimeZone
and so on, relies on java.time
API. It also natively supports ThreeTen backport project using which you can backport most of the java.time
functionality to Java 6 & 7. Check How to use ThreeTenABP in Android Project to learn how to set it up.
In case you want to replace an OOTB (Out-Of-The-Box) format e.g FormatStyle.MEDIUM
, you can always define a custom format using DateTimeFormatter
e.g.
QUESTION
I'm having some issues setting up github actions to build my kotlinJS project? i have the js runtime dependency:
...ANSWER
Answered 2021-Jun-08 at 08:57looks like this was due to an older version of kotlin-serialization dependency in kotlin-datetime updating to kotlin-datetime 0.2.1 fixed it
QUESTION
I'm getting this build error:
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option Adding support for Java 8 language features could solve this issue.
Trying to compile this build script for a multiplatform module in Android Studio:
...ANSWER
Answered 2021-Apr-09 at 16:31As per the documentation: https://kotlinlang.org/docs/mpp-dsl-reference.html#compilation-parameters
Don't be fooled by the Gradle docs' code examples into thinking a lot of this compilation syntax applies only to the Java block. This is how you specify the jvm version target for an Android build:
QUESTION
FAILURE: Build failed with an exception.
- What went wrong: Could not determine the dependencies of task ':packageJson'.
Could not resolve all dependencies for configuration ':npm'. Could not resolve org.jetbrains.kotlinx:kotlinx-datetime:0.1.0. Required by: project : > Cannot choose between the following variants of org.jetbrains.kotlinx:kotlinx-datetime:0.1.0: - jsIr-runtime - jsLegacy-runtime All of them match the consumer attributes: - Variant 'jsIr-runtime' capability org.jetbrains.kotlinx:kotlinx-datetime:0.1.0: - Unmatched attributes: - Found org.gradle.status 'release' but wasn't required. - Found org.jetbrains.kotlin.js.compiler 'ir' but wasn't required. - Compatible attributes: - Required org.gradle.usage 'kotlin-runtime' and found compatible value 'kotlin-runtime'. - Required org.jetbrains.kotlin.platform.type 'js' and found compatible value 'js'. - Variant 'jsLegacy-runtime' capability org.jetbrains.kotlinx:kotlinx-datetime:0.1.0: - Unmatched attributes: - Found org.gradle.status 'release' but wasn't required. - Found org.jetbrains.kotlin.js.compiler 'legacy' but wasn't required. - Compatible attributes: - Required org.gradle.usage 'kotlin-runtime' and found compatible value 'kotlin-runtime'. - Required org.jetbrains.kotlin.platform.type 'js' and found compatible value 'js'.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 7s
Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service. Do you accept these terms? [yes, no]
...ANSWER
Answered 2020-Aug-14 at 15:34When building a project using Kotlin 1.3.xx, you may encounter a Gradle error if one of your dependencies (or any transitive dependency) was built using Kotlin 1.4+:
This resolution problem appears because Kotlin 1.4 introduces the choice between two different compiler backends for Kotlin/JS – a choice that was not available in Kotlin 1.3.xx.
Workaround:
In order to use the libraries, create a file called workaround_to_use_1_4_libs_in_1_3.gradle.kts in the root directory of your project, and add the following code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install kotlinx-datetime
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page