We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
kotlinx-datetime是kotlin版本的日期时间库,希望能够支持以下类:
kotlinx.datetime.LocalDateTime kotlinx.datetime.LocalDate kotlinx.datetime.LocalTime
kotlinx.datetime.LocalDateTime
kotlinx.datetime.LocalDate
kotlinx.datetime.LocalTime
虽然可以自定义以下SqlType实现,但更适合集成到ktorm的库里(包括ksp):
SqlType
import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalTime /** * [SqlType] implementation represents `datetime` SQL type. */ public object LocalDateTimeSqlType : SqlType<LocalDateTime>(Types.TIMESTAMP, "datetime") { override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: LocalDateTime) { ps.setTimestamp(index, Timestamp.valueOf(parameter.toJavaLocalDateTime())) } override fun doGetResult(rs: ResultSet, index: Int): LocalDateTime? { return rs.getTimestamp(index)?.toLocalDateTime()?.toKotlinLocalDateTime() } } /** * [SqlType] implementation represents `date` SQL type. */ public object LocalDateSqlType : SqlType<LocalDate>(Types.DATE, "date") { override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: LocalDate) { ps.setDate(index, Date.valueOf(parameter.toJavaLocalDate())) } override fun doGetResult(rs: ResultSet, index: Int): LocalDate? { return rs.getDate(index)?.toLocalDate()?.toKotlinLocalDate() } } /** * [SqlType] implementation represents `time` SQL type. */ public object LocalTimeSqlType : SqlType<LocalTime>(Types.TIME, "time") { override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: LocalTime) { ps.setTime(index, Time.valueOf(parameter.toJavaLocalTime())) } override fun doGetResult(rs: ResultSet, index: Int): LocalTime? { return rs.getTime(index)?.toLocalTime()?.toKotlinLocalTime() } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
kotlinx-datetime是kotlin版本的日期时间库,希望能够支持以下类:
kotlinx.datetime.LocalDateTime
kotlinx.datetime.LocalDate
kotlinx.datetime.LocalTime
虽然可以自定义以下
SqlType
实现,但更适合集成到ktorm的库里(包括ksp):The text was updated successfully, but these errors were encountered: