Local Date Time
See original GitHub issueHey guys,
I’ve been using Exposed to create a database for some timeseries data. I’ve noticed the following code in ColumnType.kt:
class DateColumnType(val time: Boolean): ColumnType() {
override fun sqlType(): String = if (time) currentDialect.dataTypeProvider.dateTimeType() else "DATE"
override fun nonNullValueToString(value: Any): String {
if (value is String) return value
val dateTime = when (value) {
is DateTime -> value
is java.sql.Date -> DateTime(value.time)
is java.sql.Timestamp -> DateTime(value.time)
else -> error("Unexpected value: $value of ${value::class.qualifiedName}")
}
return if (time)
"'${DEFAULT_DATE_TIME_STRING_FORMATTER.print(dateTime.toDateTime(DateTimeZone.getDefault()))}'"
else
"'${DEFAULT_DATE_STRING_FORMATTER.print(dateTime)}'"
}
This uses DateTimeZone.getDefault()
to get the string for the DateTime value. However, I do not want to use the System Locale Timezone to save values on the DB. Could we make a change to specify the timezone to use? Another (maybe easier) solution would be to include functionality for Joda’s LocalDateTime instead.
Let me know what you guys think.
Fred
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
LocalDateTime (Java Platform SE 8 ) - Oracle Help Center
LocalDateTime is an immutable date-time object that represents a date-time, often viewed as year-month-day-hour-minute-second. Other date and time fields, ...
Read more >Java 8 Date - LocalDate, LocalDateTime, Instant - DigitalOcean
LocalDate is an immutable class that represents Date with default format of yyyy-MM-dd. We can use now() method to get the current date....
Read more >Java LocalDateTime - Javatpoint
Java LocalDateTime class is an immutable date-time object that represents a date-time, with the default format as yyyy-MM-dd-HH-mm-ss.zzz.
Read more >java.time.LocalDateTime Class in Java - GeeksforGeeks
time.LocalDateTime class, introduced in Java 8, represents a local date-time object without timezone information. The LocalDateTime class in ...
Read more >Guide to Java LocalDateTime - HowToDoInJava
Java LocalDateTime class, introduced in Java 8, represents a local date time object without timezone information. It is immutable and thread ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Tapac That is not a solution to this issue. I argue this should be re-opened. Java LocalDateTime does not use a time zone. IF we use a LocalDateTime with exposed, it will assume system default time zone on insert.
I was going to tryout exposed. However, the lack of ZonedDateTime means I will use Hibernate/JPA. I don’t really have a choice. My company decided a few years ago was that everything would be GMT going forward, but we can’t change all of the servers to GMT because of older existing software. Exposed looks promising, but it needs it needs full support for the java 8 date/time api.