toString

actual open override fun toString(): String(source)
expect open override fun toString(): String(source)

Converts this date/time value to the ISO 8601 string representation.

For readability, if the time represents a round minute (without seconds or fractional seconds), the string representation will not include seconds. Also, fractions of seconds will add trailing zeros to the fractional part until its length is a multiple of three.

Examples of output:

  • 2020-08-30T18:43

  • 2020-08-30T18:43:00

  • 2020-08-30T18:43:00.500

  • 2020-08-30T18:43:00.123456789

See also

for details of how the time part is formatted.

for a very similar format. The difference is that Formats.ISO will always include seconds, even if they are zero, and will not add trailing zeros to the fractional part of the second for readability.

for the dual operation: obtaining LocalDateTime from a string.

for formatting using a custom format.

actual open override fun toString(): String(source)
actual open override fun toString(): String(source)