@@ -4,6 +4,8 @@ import kotlinx.datetime.Instant
4
4
import kotlinx.datetime.LocalDate
5
5
import kotlinx.datetime.LocalDateTime
6
6
import kotlinx.datetime.TimeZone
7
+ import kotlinx.datetime.atStartOfDayIn
8
+ import kotlinx.datetime.atTime
7
9
import kotlinx.datetime.toInstant
8
10
import kotlinx.datetime.toJavaLocalDate
9
11
import kotlinx.datetime.toJavaLocalDateTime
@@ -217,16 +219,25 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
217
219
java.time.LocalDateTime ::class -> when (toClass) {
218
220
LocalDate ::class -> convert< java.time.LocalDateTime > { it.toKotlinLocalDateTime().date }
219
221
LocalDateTime ::class -> convert< java.time.LocalDateTime > { it.toKotlinLocalDateTime() }
222
+ Instant ::class -> convert< java.time.LocalDateTime > { it.toKotlinLocalDateTime().toInstant(defaultTimeZone) }
220
223
Long ::class -> convert< java.time.LocalDateTime > { it.toKotlinLocalDateTime().toInstant(defaultTimeZone).toEpochMilliseconds() }
221
224
java.time.LocalDate ::class -> convert< java.time.LocalDateTime > { it.toLocalDate() }
222
225
else -> null
223
226
}
224
227
LocalDate ::class -> when (toClass) {
228
+ LocalDateTime ::class -> convert<LocalDate > { it.atTime(0 , 0 ) }
229
+ Instant ::class -> convert<LocalDate > { it.atStartOfDayIn(defaultTimeZone) }
230
+ Long ::class -> convert<LocalDate > { it.atStartOfDayIn(defaultTimeZone).toEpochMilliseconds() }
225
231
java.time.LocalDate ::class -> convert<LocalDate > { it.toJavaLocalDate() }
232
+ java.time.LocalDateTime ::class -> convert<LocalDate > { it.atTime(0 , 0 ).toJavaLocalDateTime() }
226
233
else -> null
227
234
}
228
235
java.time.LocalDate ::class -> when (toClass) {
229
236
LocalDate ::class -> convert< java.time.LocalDate > { it.toKotlinLocalDate() }
237
+ LocalDateTime ::class -> convert< java.time.LocalDate > { it.atTime(0 , 0 ).toKotlinLocalDateTime() }
238
+ Instant ::class -> convert< java.time.LocalDate > { it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone) }
239
+ Long ::class -> convert< java.time.LocalDate > { it.toKotlinLocalDate().atStartOfDayIn(defaultTimeZone).toEpochMilliseconds() }
240
+ java.time.LocalDateTime ::class -> convert< java.time.LocalDate > { it.atStartOfDay() }
230
241
else -> null
231
242
}
232
243
URL ::class -> when (toClass) {
0 commit comments