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 ...
随机推荐
- zoj 3460 Missile【经典建图&&二分】
Missile Time Limit: 2 Seconds Memory Limit: 65536 KB You control N missile launching towers. Ev ...
- ADODB.Connection 错误 '800a0e7a' 未找到提供程序 该程序可能未正确安装
今天调程序的时候发现的,错误提示如下: ADODB.Connection 错误 '800a0e7a' 未找到提供程序.该程序可能未正确安装. /conn.asp,行 6 因为系统是64位的win7或w ...
- python学习之列表
#coding:utf-81.#reverse方法将列表的元素反向存放,改变了原列表但不返回值x=[5,2,4,3,8]x.reverse() #x[::-1] 不改变list反向排序print x ...
- linux下查询域名或IP注册信息的操作记录(whois)
在运维工作中,有时需要查询某些域名的注册信息(域名的NS,注册用户,注册邮箱等),可以使用whois这个命令.whois命令令用来查找并显示指定帐号(或域名)的用户相关信息,因为它是到Network ...
- 微信开发第8章 通过accesstoken将长连接转换为短链接
业务场景:开发的过程中经常会有一些很长的链接,这个时候如果生成二维码,会导致扫码的过程中识别比较慢,如果存入数据库,会导致数据库的字段长度要设定的很长才行,所以把长连接转换为短链接就越来越重要了. 接 ...
- Objective-C-使用NSMutableURLRequest发送POST请求,使用NSJSONSerialization解析JSON字符串
NSString *reqData = @"Data="; NSData *postDatas = nil; NSString *urlPath = @"url" ...
- cluster模块实现多进程-让我的代理服务速度飞起来了
cluster模块实现多进程 现在的cluster已经可以说完全做到的负载均衡,在做代理服务和http服务器的时候能够讲服务器性能发挥到最大.来看一下具体的实现吧 var cluster = requ ...
- 【开发工具 - Git】之Git常用命令汇总
本文记录了Git Bash中的常用指令. 1 Git操作 git clone XXXXX:将GitHub项目XXXXX克隆到本地 git remote –v:查看远程连接信息 git ch ...
- SQLite的SQL语法
SQLite库能够解析大部分标准SQL语言.但它也省去了一些特性而且增加了一些自己的新特性.这篇文档就是试图描写叙述那些SQLite支持/不支持的SQL语法的.查看keyword列表. 例如以下语法表 ...
- 69 Spring Interview Questions and Answers – The ULTIMATE List--reference
This is a summary of some of the most important questions concerning the Spring Framework, that you ...