I use nsacala-time package from https://github.com/nscala-time/nscala-time.
import com.github.nscala_time.time.Imports._
DateTime.now.hour(0)
res0: org.joda.time.DateTime = 2015-06-11T22:33:52.266+08:00
will get a new DateTime object. But in the source,https://github.com/nscala-time/nscala-time/blob/master/src/main/scala/com/github/nscala_time/time/RichDateTime.scala ,it does not have a hour function with signature (Int). It seems that withHour(hour: Int) do the exact work.
Implicit conversions everywhere (a.k.a Black Magic, a.k.a why everyone hates Scala)!!!
hour
returns aorg.joda.time.DateTime.Property
.Import._
imports theRichDateTimeProperty
RichDateTimeProperty
has anapply
method defined and by default in Scala doingsomething()
ifsomething
is not a method gets translated tosomething.apply()
, so finally this method is invoked via 2 implicit conversions: