init {
val config = HikariConfig()
- config.jdbcUrl = "jdbc:h2:~/.rssreader/feeds"
+ config.jdbcUrl = "jdbc:h2:~/.rssreader/feeds;TIME ZONE=UTC"
config.maximumPoolSize = 16
dataSource = HikariDataSource(config)
item.category = rs.getString("category")
item.description = rs.getString("description")
item.author = rs.getString("author")
- item.pubDate = rs.getObject("pub_date", java.time.LocalDateTime::class.java)
- item.updated = rs.getObject("updated", java.time.LocalDateTime::class.java)
+ item.pubDate = rs.getTimestamp("pub_date")?.toInstant();
+ item.updated = rs.getTimestamp("updated")?.toInstant();
item.guid = rs.getString("guid")
item.contentText = rs.getString("contentText")
item.contentHtml = rs.getString("contentHTML")
stmt.setString(4, item.category)
stmt.setString(5, item.description)
stmt.setString(6, item.author)
- stmt.setTimestamp(7, item.pubDate?.let { java.sql.Timestamp.valueOf(it) })
- stmt.setTimestamp(8, item.updated?.let { java.sql.Timestamp.valueOf(it) })
+ stmt.setTimestamp(7, item.pubDate?.let { java.sql.Timestamp.from(it) })
+ stmt.setTimestamp(8, item.updated?.let { java.sql.Timestamp.from(it) })
stmt.setString(9, item.guid)
stmt.setString(10, item.contentText)
stmt.setString(11, item.contentHtml)
public fun updateFeedDate(feed: Feed) {
dataSource.connection.use { conn ->
- feed.lastUpdate = java.time.LocalDateTime.now()
+ feed.lastUpdate = java.time.Instant.now()
conn.prepareStatement("""
update feeds set last_update = now() where feed_id = ?
""".trimIndent()).use { stmt ->
package de.unixwork.rssreader
-import java.time.LocalDateTime
+import java.time.Instant
class Feed(id: Int, feedCollectionId: Int, uri: String) {
var user: String? = null
var password: String? = null
var certpath: String? = null
- var lastUpdate: LocalDateTime? = null
+ var lastUpdate: Instant? = null
}
package de.unixwork.rssreader
-import java.time.LocalDateTime
+import java.time.Instant
class Item(id: Int) {
var category: String? = null
var description: String? = null
var author: String? = null
- var pubDate: LocalDateTime? = null
- var updated: LocalDateTime? = null
+ var pubDate: Instant? = null
+ var updated: Instant? = null
var guid: String? = null
var contentText: String? = null
var contentHtml: String? = null
import de.unixwork.ui.kotlin.sidebarWindow
import de.unixwork.ui.kotlin.dialogWindow
import de.unixwork.ui.kotlin.openFileDialog
+import java.time.ZoneId
import java.time.format.DateTimeFormatter
class MainWindow {
val feedList = FeedList()
// TODO: date format config
- val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
+ val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault())
var newFeedPrevGroup = 0
var result: String? = null
when(col) {
0 -> result = elm.title
- 1 -> result = elm.updated?.format(formatter) ?: elm.pubDate?.format(formatter)
+ 1 -> result = formatter.format(elm.updated ?: elm.pubDate)
}
result
}
item.description = entry.description?.value
item.author = entry.author
entry.publishedDate?.let {
- item.pubDate = it.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime()
+ item.pubDate = it.toInstant()
}
entry.updatedDate?.let {
- item.updated = it.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime()
+ item.updated = it.toInstant()
}
item.guid = entry.uri
val contents = entry.contents