-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
Description
Hello.
I use Play 2.6.0.
Have following Form
val form = Form(
mapping(
"reg_date" -> optional(sqlDate("dd.MM.yyyy")),
"reg_limit" -> optional(sqlDate("dd.MM.yyyy")),
"unreg_date" -> optional(sqlDate("dd.MM.yyyy"))
)(Reg.apply)(Reg.unapply)
)And getting runtime error:
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[UnsupportedOperationException: null]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:255)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:182)
at play.core.server.AkkaHttpServer$$anonfun$$nestedInanonfun$executeHandler$1$1.applyOrElse(AkkaHttpServer.scala:230)
at play.core.server.AkkaHttpServer$$anonfun$$nestedInanonfun$executeHandler$1$1.applyOrElse(AkkaHttpServer.scala:229)
at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:412)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at play.api.libs.streams.Execution$trampoline$.executeScheduled(Execution.scala:109)
at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:71)
at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:68)
Caused by: java.lang.UnsupportedOperationException: null
at java.sql.Date.toInstant(Date.java:304)
at play.api.data.format.Formats$$anon$7.unbind(Format.scala:212)
at play.api.data.format.Formats$$anon$7.unbind(Format.scala:199)
at play.api.data.format.Formats$$anon$8.unbind(Format.scala:236)
at play.api.data.format.Formats$$anon$8.unbind(Format.scala:226)
at play.api.data.FieldMapping.unbind(Form.scala:911)
at play.api.data.OptionalMapping.$anonfun$unbind$3(Form.scala:824)
at scala.Option.map(Option.scala:146)
at play.api.data.OptionalMapping.unbind(Form.scala:824)
at play.api.data.OptionalMapping.unbind(Form.scala:776)
I think cause line 212 in api\data\format\Format.scala:
def unbind(key: String, value: Date) = Map(key -> formatter.format(value.toInstant.atZone(javaTimeZone)))As said in Java Docs:
public Instant toInstant()
This method always throws an UnsupportedOperationException and should not be used because SQL Date values do not have a time component.
Reactions are currently unavailable