You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to define a custom format similar to how a custom parser can be defined. Something like:
val customFormat = dateTimeFormat {
monthNumber()
+'/'
dayOfMonth()
}
val date =Date(2019, 10, 28)
val string = date.toString(customFormat)
For the initial implementation, we can avoid adding support anything locale-specific. Locale will open up another can of worms.
Implementing this will probably require inserting an interface into the date-time primitives -- something akin to TemporalAccessor in java.time, but Period and Duration should also implement it since we include parser support for them. This interface should provide access to the available date-time fields on the object.
interface Temporal {
fun get(field: DateTimeField): Long
}
Introducing a TemporalQuery-like interface for access to non-Long fields may also be necessary.
Ultimately, I'm envisioning the abstractions added here will also tie in with and enable parsing of arbitrary ISO-compliant strings.
val temporal = genericIsoParser.parseAny(text)
if (temporal isYear) {
// ..
} elseif (temporal isDate) {
// ..
}
This will be useful for working with intervals that have mixed-precision end points, like "2018/2019-05-01".
Obviously, these are more advanced use cases though, so the focus should initially be on what's necessary to support custom formatting.
The text was updated successfully, but these errors were encountered:
It should be possible to define a custom format similar to how a custom parser can be defined. Something like:
For the initial implementation, we can avoid adding support anything locale-specific. Locale will open up another can of worms.
Implementing this will probably require inserting an interface into the date-time primitives -- something akin to
TemporalAccessor
in java.time, butPeriod
andDuration
should also implement it since we include parser support for them. This interface should provide access to the available date-time fields on the object.Introducing a
TemporalQuery
-like interface for access to non-Long fields may also be necessary.Ultimately, I'm envisioning the abstractions added here will also tie in with and enable parsing of arbitrary ISO-compliant strings.
This will be useful for working with intervals that have mixed-precision end points, like "2018/2019-05-01".
Obviously, these are more advanced use cases though, so the focus should initially be on what's necessary to support custom formatting.
The text was updated successfully, but these errors were encountered: