Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From Java SE 8 onwards, users are asked to migrate to java.time (JSR-310). There are efforts on creating scala libraries wrapping java.time for scala such as <a href="https://github.com/reactivecodes/scala-time" rel="noreferrer">scala-time</a>. If targeting lower than SE 8 use one of the below. Also see <a href="http://blog.joda.org/2009/11/why-jsr-310-isn-joda-time_4941.html" rel="noreferrer">Why JSR-310 isn't Joda-Time</a></p> <hr> <p><a href="https://github.com/nscala-time/nscala-time" rel="noreferrer">A new Scala wrapper for Joda Time</a>. This project forked from scala-time since it seems that scala-time is no longer maintained.</p> <pre><code>import com.github.nscala_time.time.Imports._ DateTime.now // returns org.joda.time.DateTime = 2009-04-27T13:25:42.659-07:00 DateTime.now.hour(2).minute(45).second(10) // returns org.joda.time.DateTime = 2009-04-27T02:45:10.313-07:00 DateTime.now + 2.months // returns org.joda.time.DateTime = 2009-06-27T13:25:59.195-07:00 DateTime.nextMonth &lt; DateTime.now + 2.months // returns Boolean = true DateTime.now to DateTime.tomorrow // return org.joda.time.Interval = &gt; 2009-04-27T13:47:14.840/2009-04-28T13:47:14.840 (DateTime.now to DateTime.nextSecond).millis // returns Long = 1000 2.hours + 45.minutes + 10.seconds // returns com.github.nscala_time.time.DurationBuilder // (can be used as a Duration or as a Period) (2.hours + 45.minutes + 10.seconds).millis // returns Long = 9910000 2.months + 3.days // returns Period </code></pre> <p><a href="http://joda-time.sourceforge.net/" rel="noreferrer">Joda Time</a> is a good Java library, there is a Scala wrapper / implicit conversion library avaliable for Joda Time at <a href="http://github.com/jorgeortiz85/scala-time/tree/master" rel="noreferrer">scala-time</a> created by <a href="http://github.com/jorgeortiz85" rel="noreferrer">Jorge Ortiz</a>. (Note implicits have a performance hit, but it depends on what you do if you will notice. And if you run into a performance problem you can just revert to the Joda interface)</p> <p>From the README:</p> <pre><code>USAGE: import org.scala_tools.time.Imports._ DateTime.now // returns org.joda.time.DateTime = 2009-04-27T13:25:42.659-07:00 DateTime.now.hour(2).minute(45).second(10) // returns org.joda.time.DateTime = 2009-04-27T02:45:10.313-07:00 DateTime.now + 2.months // returns org.joda.time.DateTime = 2009-06-27T13:25:59.195-07:00 DateTime.nextMonth &lt; DateTime.now + 2.months // returns Boolean = true DateTime.now to DateTime.tomorrow // return org.joda.time.Interval = // 2009-04-27T13:47:14.840/2009-04-28T13:47:14.840 (DateTime.now to DateTime.nextSecond).millis // returns Long = 1000 2.hours + 45.minutes + 10.seconds // returns org.scala_tools.time.DurationBuilder // (can be used as a Duration or as a Period) (2.hours + 45.minutes + 10.seconds).millis // returns Long = 9910000 2.months + 3.days // returns Period </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload