use datetime
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-08-18 15:31:12 +02:00
parent e4bcfab2af
commit 2ae6742cd5
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
3 changed files with 8 additions and 8 deletions

View File

@ -1,11 +1,11 @@
package api
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
import kotlinx.serialization.Serializable
@Serializable
data class ApiObject(
val tag: String,
val device_id: Int,
val device_date: LocalDate
val device_date: LocalDateTime
)

View File

@ -2,13 +2,13 @@ package database.dao
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.`java-time`.date
import java.time.LocalDate
import org.jetbrains.exposed.sql.`java-time`.datetime
import java.time.LocalDateTime
object SampleObjects : IntIdTable() {
val tag: Column<String> = varchar("tag", 32)
val timestamp: Column<LocalDate> = date("timestamp").default(LocalDate.now())
val timestamp: Column<LocalDateTime> = datetime("timestamp").default(LocalDateTime.now())
val device_id: Column<Int> = integer("device_id")
val device_date: Column<LocalDate> = date("device_date")
val device_date: Column<LocalDateTime> = datetime("device_date")
override val primaryKey = PrimaryKey(id, name = "PK_SampleObject_Id")
}

View File

@ -2,7 +2,7 @@ package database.service
import database.model.SampleObject
import api.ApiObject
import kotlinx.datetime.toJavaLocalDate
import kotlinx.datetime.toJavaLocalDateTime
import org.jetbrains.exposed.sql.transactions.transaction
class SampleObjectService : ISampleObjectService {
@ -11,7 +11,7 @@ class SampleObjectService : ISampleObjectService {
transaction {
SampleObject.new {
tag = apiObject.tag
device_date = apiObject.device_date.toJavaLocalDate()
device_date = apiObject.device_date.toJavaLocalDateTime()
device_id = apiObject.device_id
}
}