I am trying to cast com.github.nscala_time.time.Imports.DateTime from nscala-time (a wrapper of joda-time) to java.util.Date
activeUntil.toDate()
But I get this error
value toDate is not a member of Option[com.github.nscala_time.time.Imports.DateTime]
Obviuosly is not the right way to do it. Is there a way to do this?
Thank you in advance
Apparently
activeUntil
is anOption[DateTime]
notDateTime
itself. You canmap
it toDate
and get providing some default value in caseOption
is empty like thisI am not sure where did you get
activeUntil
from, but probably from a method that can fail to give you yourDateTime
this is why it returned anOption
and forced you to handle the case when there is nothing to return.