scala处理日期
scala 日期處理
https://github.com/nscala-time/nscala-time
For processing dates, the Java Joda Time project is popular and well documented. A project named?nscala-time?implements a Scala wrapper around Joda Time, and lets you write date expressions in a more Scala-like way, including these examples:
DateTime.?now?//?returns?org.joda.time.DateTime DateTime.?now?+?2.?months DateTime.?nextMonth?<?DateTime.?now?+?2.?months (2.?hours?+?45.?minutes?+?10.?seconds).?millis如何引入依賴
<dependency><groupId>com.github.nscala-time</groupId><artifactId>nscala-time_2.10</artifactId><version>2.0.0</version></dependency>代碼示例
import?com.github.nscala_time.time.Imports._object?HelloWorld?{def?main(args:?Array[String])?{println(DateTime.now?+?2.months)?//?returns?org.joda.time.DateTime?=?2009-06-27T13:25:59.195-07:00println(DateTime.nextMonth?<?DateTime.now?+?2.months)?//?returns?Boolean?=?trueprintln(DateTime.now?to?DateTime.tomorrow)?//?return?org.joda.time.Interval?=?>?2009-04-27T13:47:14.840/2009-04-28T13:47:14.840println((DateTime.now?to?DateTime.nextSecond).millis)?//?returns?Long?=?1000println((2.hours?+?45.minutes?+?10.seconds))//?returns?com.github.nscala_time.time.DurationBuilder//?(can?be?used?as?a?Duration?or?as?a?Period)println((2.hours?+?45.minutes?+?10.seconds).millis)//?returns?Long?=?9910000println(2.months?+?3.days)//?returns?Period} }總結(jié)
- 上一篇: CSS相邻兄弟选择器
- 下一篇: UITableView移除某一行cell