Scala-processing time (Nscala-time-joda in Scala package)

Source: Internet
Author: User

Github:https://github.com/nscala-time/nscala-time

MAVEN: (Pay attention to the Scala version)

<Dependency>    <groupId>Com.github.nscala-time</groupId>    <Artifactid>nscala-time_2.10</Artifactid>    <version>2.6.0</version></Dependency>


code example:

Remember import com.github.nscala_time.time.imports._

scala> DateTime.Parse ("20150101", DateTimeFormat forpattern ("YyyyMMdd"))
Res11:org.joda.time.DateTime = 2015-01-01t00:00:00.000+08:00

scala> DateTime.Parse ("2015-01-01")
Res12:org.joda.time.DateTime = 2015-01-01t00:00:00.000+08:00

scala> DateTime.Parse ("2015-01-01t08:23:56")
Res13:org.joda.time.DateTime = 2015-01-01t08:23:56.000+08:00

scala> DateTime.Now + 2.months
Res14:org.joda.time.DateTime = 2016-03-20t17:46:31.288+08:00

scala> Datetime.nextmonth < DateTime.Now + 2.month
Res15:boolean = True

scala> DateTime.Now to Datetime.tomorrow
Res16:org.joda.time.Interval = 2016-01-20t17:46:31.743+08:00/2016-01-21t17:46:31.743+08:00

scala> (DateTime.Now to Datetime.nextsecond). Millis
Res17:long = 1000

scala> 2.hours + 45.minutes + 10.seconds
Res18:com.github.nscala_time.time.DurationBuilder = [email protected]

scala> (2.hours + 45.minutes + 10.seconds). Millis
Res19:long = 9910000

scala> 2.months + 3.days
Res20:org.joda.time.Period = P2m3d

scala> DateTime.now.hour (2). minute. Second (10)
Res21:org.joda.time.DateTime = 2016-01-20t02:45:10.762+08:00

Scala-processing time (Nscala-time-joda in Scala package)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.