Scala - 处理时间(nscala-time - Joda Time的scala封装)
GITHUB : https://github.com/nscala-time/nscala-time
MAVEN : (注意选对scala版本)
<dependency>
<groupId>com.github.nscala-time</groupId>
<artifactId>nscala-time_2.10</artifactId>
<version>2.6.0</version>
</dependency>
代码示例:
记得 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 = com.github.nscala_time.time.DurationBuilder@90c70e54
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(45).second(10)
res21: org.joda.time.DateTime = 2016-01-20T02:45:10.762+08:00
Scala - 处理时间(nscala-time - Joda Time的scala封装)的更多相关文章
- Beginning Scala study note(4) Functional Programming in Scala
1. Functional programming treats computation as the evaluation of mathematical and avoids state and ...
- Beginning Scala study note(3) Object Orientation in Scala
1. The three principles of OOP are encapsulation(封装性), inheritance(继承性) and polymorphism(多态性). examp ...
- Beginning Scala study note(1) Geting Started with Scala
1. Scala is a contraction of "scalable" and "language". It's a fusion of objecte ...
- Scala 深入浅出实战经典 第49课 Scala中Variance代码实战(协变)
王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...
- 【Scala学习笔记】第01弹——Scala安装与配置
安装Scala之前先要安装JDK(1.5以上),最好安装JDK 1.8+,安装好JDK后配置JDK的环境变量. 然后去Scala官网(http://www.scala-lang.org/downloa ...
- Scala入门(1)Linux下Scala(2.12.1)安装
Scala入门(1)Linux下Scala(2.12.1)安装 一.文件准备 1.1 文件名称 scala-2.12.1.tgz 1.2 下载地址 http://www.scala-lang.org/ ...
- Scala学习之路 (七)Scala的柯里化及其应用
一.概念 柯里化(currying, 以逻辑学家Haskell Brooks Curry的名字命名)指的是将原来接受两个参数的函数变成新的接受一个参数的函数的过程.新的函数返回一个以原有第二个参数作为 ...
- Scala学习之路 (四)Scala的数组、映射、元组、集合
一.数组 1.定长数组和变长数组 import scala.collection.mutable.ArrayBuffer object TestScala { def main(args: Array ...
- Scala学习之路 (三)Scala的基本使用
一.Scala概述 scala是一门多范式编程语言,集成了面向对象编程和函数式编程等多种特性.scala运行在虚拟机上,并兼容现有的Java程序.Scala源代码被编译成java字节码,所以运行在JV ...
随机推荐
- Redis在PHP中的基本使用案例
下载http://www.oschina.net/p/redis 解压后里面有:lib 源文件 .examples 例子.test测试 将lib目录拷贝到你的项目中,就可以开始你的predis操作了. ...
- SSIS执行SQL任务时加入参数
昨天开发的SSIS包中,获取ERP系统parttran表时,数据量比较大,达到255万多,因为SQL执行的关系,致使处理时效率很慢,所以就想用增量更新的方法处理该表数据.这是增量更新的SQL任务集合, ...
- Ubuntu 12.04 升级到14.04之后,pidgin-sipe 出现的问题: Trouble with the pidgin and self-signed SSL certificate
Once again, I run into trouble when upgrading my LinuxMint. In last few days, my Linux mint notifies ...
- UVA Knight Moves
题目例如以下: Knight Moves A friend of you is doing research on the Traveling Knight Problem (TKP) where ...
- [React] React Fundamentals: Mixins
Mixins will allow you to apply behaviors to multiple React components. Components are the best way t ...
- css匹配原理与优化
一. 匹配原理 浏览器CSS匹配不是从左到右进行查找,而是从右到左进行查找.比如之前说的 DIV#divBox p span.red{color:red;},浏览器的查找顺序如下:先查找 html 中 ...
- LINUX 系统备份
系统备份是系统管理工作中十分重要的一个环切,本文详细介绍了各种Linux系统的备份方法,相信对大家的日常管理工作有所帮助. 备份是一项重要的工作,但是很多人没有去做.一旦由于使用不当造成数据丢失,备份 ...
- 【转】C/C++求模求余运算符——2013-08-20
http://blog.csdn.net/whealker/article/details/6203629 求模运算符(%),或称求余运算符,也就是数学上所谓的除法中的余数,%两侧均应为整数, |小| ...
- merge into sql优化
今天网友说他的merge into sql跑了15分钟了还没有跑出数据,问我能不能优化一下,我让他把sql和sql的执行计划发过来 merge into F_Sal_P_Camp_Samp_Cust_ ...
- 通过配置tomcat虚拟路径配置站点的静态资源
我们常常站点中会提供给用户上传文件.图片.视频或者诸如为了提高性能生成的静态文件等存储在站点应用中.但如果静态资源文件和项目文件在同一个目录下,当我们重新部署文件时,war重新解压会导致静态资源文件的 ...