算出一个两个时间段中的所有天
来源:互联网 发布:关闭淘宝手机支付 编辑:程序博客网 时间:2024/05/29 16:09
def getDateRange(startTime:String,endTime:String) = {
val dateFormat = new SimpleDateFormat("yyyy-MM-dd")
val dateFiled = Calendar.DAY_OF_MONTH
var beginDate = dateFormat.parse(startTime)
val endDate = dateFormat.parse(endTime)
val calendar = Calendar.getInstance()
calendar.setTime(beginDate)
val dateArray : ArrayBuffer[String] = ArrayBuffer()
while(beginDate.compareTo(endDate) <= 0){
dateArray += dateFormat.format(beginDate)
calendar.add(dateFiled, 1)
beginDate = calendar.getTime
}
dateArray.toList
val dateFormat = new SimpleDateFormat("yyyy-MM-dd")
val dateFiled = Calendar.DAY_OF_MONTH
var beginDate = dateFormat.parse(startTime)
val endDate = dateFormat.parse(endTime)
val calendar = Calendar.getInstance()
calendar.setTime(beginDate)
val dateArray : ArrayBuffer[String] = ArrayBuffer()
while(beginDate.compareTo(endDate) <= 0){
dateArray += dateFormat.format(beginDate)
calendar.add(dateFiled, 1)
beginDate = calendar.getTime
}
dateArray.toList
}
测试:
def main(args: Array[String]) {
val index = getDateRange("2017-05-20","2017-06-01")
println("两个时间相隔所有天:"+index.mkString(","))
}
结果:
阅读全文
0 0
- 算出一个两个时间段中的所有天
- 获取一个时间段内所有天(年月日)
- 两个时间段内的所有年月
- 递归算出两个数字之间所有数字之和
- 毕业设计至获取两个时间段时间的所有日期
- Oracle 查询两个时间段内的所有日期列表
- java 两个时间段有多少天
- 程序算出一个文件夹中所有文件的行数
- Oracle如何获取一个时间段内的所有日期
- Oracle如何根据一个时间段内的所有日期
- oracle 根据一个时间段获取这个时间段内所有月份、天数、日期
- 趣题:用两个2算出一个5
- 写一个函数,算出两个文件的相对路径?
- 输入一个正数s,打印出所有和为s的连续正数序列(至少包含两个数)
- 算出所有不能写成两个过剩数之和的正整数之和。
- 深搜法:模拟地铁路线算出两个站点之间的距离和所有通过的可能
- 两个时间段取得交集
- SQL中获取指定两个日期时间点或者时间段内所有记录语句
- Spark 简单实例(基本操作)
- Android广播
- Android opengl 正方形 手势三维旋转、缩小、放大
- C# 泛型
- Mysql主从延迟过高导致的case
- 算出一个两个时间段中的所有天
- DrawerLayout的使用
- 使用G2做出丰富多彩的词云
- KOtlin 基本语法
- 设计模式总结
- 制作OpenSUSE12.3的OpenStack镜像
- tcp ip在线阅读http://www.52im.net/topic-tcpipvol1.html
- Java实现二叉树镜像 变换
- c++获取OpenGL版本号的两种方法