New issue
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
java8 date apis #111
Comments
+1 using JodaTime currently and would like to remove the external dep (since java 8 date api is based on JodaTime) |
are we aiming to only support Java8? For me it's a +1 but I would like to hear the opinion of others. |
+1 to Java 8 only |
@lvicentesanchez no, I've removed it because eclipse doesn't like it. |
@godenji do you happen to have a working example of joda DateTime with Quill? I try to provide the encoding with
but still get the following error:
Looking at the code from quill-pgsql, it seems to be far more involved. |
This works for me, maybe I missunderstood what do you want to do :( |
@beikern - hey, thanks for looking into it. Still missing something here unfortunately. Perhaps I am misunderstanding how this should be done entirely :) Full original example:
Last line results in the When I replace the two Perhaps you do have a more complete example? |
I've tried this now and It works as expected :) Hope it's useful to you! |
@ksilin This should work import java.time.{ LocalDateTime, ZoneId, ZoneOffset }
import java.util.Date
import io.getquill._
import io.getquill.naming.UpperCase
import scala.concurrent.ExecutionContext.Implicits.global
object Main extends App {
implicit val decodeLocalTime = mappedEncoding[Date, LocalDateTime](date => LocalDateTime.ofInstant(date.toInstant, ZoneId.systemDefault()))
implicit val encodeLocalTime = mappedEncoding[LocalDateTime, Date](time => new Date(time.toEpochSecond(ZoneOffset.of(ZoneId.systemDefault().getId))))
case class Simple(name: String, date: LocalDateTime)
val db = source(new CassandraAsyncSourceConfig[UpperCase]("local-cass"))
val insertQuery = quote { s: Simple => query[Simple].insert(s) }
val insert = db.run(insertQuery)(List(Simple("a", LocalDateTime.now())))
} |
Yay, learning! Both variants work. Many thanks to both of you!
|
note for people encountering this issue: |
@lvicentesanchez Just stumbled over your example for def DateToLDT(date: Date) = LocalDateTime.ofInstant(date.toInstant, ZoneOffset.UTC)
def LDTToDate(time: LocalDateTime) = new Date(time.toInstant(ZoneOffset.UTC).toEpochMilli) // this uses toEpochMilli instead of toEpochSecond |
Quill currently using
java.util.Date
The text was updated successfully, but these errors were encountered: