-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Previous/next date and/or time with the given form #325
Comments
One practical use case for such functionality: the OCPP specification. It mandates that ISO date/time strings don't have more than 3 decimal points:
In other words: no more than millisecond precision. While working with We could use JSR-310 ( |
Update: I found a single-line workaround for forcibly reducing the precision to millisecond-level in serialized ISO date/time strings, at least for timestamps originating from the system clock: import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
// Will have 6 digits behind the decimal point on Kotlin/JVM, but 3 digits on Kotlin/JS and Kotlin/Native
println(Clock.System.now())
// Will have 3 digits behind the decimal point on Kotlin/JVM, Kotlin/JS and Kotlin/Native
println(Instant.fromEpochMilliseconds(Clock.System.now().toEpochMilliseconds())) So Kotlin/JVM appears to appears to be the only Kotlin platform that creates |
@volkert-fastned, since your problem is with system interoperability, the upcoming API for parsing and formatting may solve it: #343 |
"I have a date or a time, and I want to round/adjust it."
Examples:
Duration
: Feature Request: truncateTo for LocalTime #225 (comment) (can also be solved by tweaking the formatter).The text was updated successfully, but these errors were encountered: