时分秒时间段的区域判断
来源:互联网 发布:淘宝点了收藏没反应 编辑:程序博客网 时间:2024/06/05 19:06
/** * 判断某一时间是否在一个区间内 * * @param sourceTime * 时间区间,半闭合,如[10:00:00-20:00:00] * @param curTime * 需要判断的时间 如10:00:00 * @return * @throws IllegalArgumentException */ public static boolean isInTimeForS(String sourceTime, String curTime) { if (sourceTime == null || !sourceTime.contains("-") || !sourceTime.contains(":")) { throw new IllegalArgumentException("Illegal Argument arg:" + sourceTime); } if (curTime == null || !curTime.contains(":")) { throw new IllegalArgumentException("Illegal Argument arg:" + curTime); } String[] args = sourceTime.split("-"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); try { long now = sdf.parse(curTime).getTime(); long start = sdf.parse(args[0]).getTime(); long end = sdf.parse(args[1]).getTime(); if (args[1].equals("00:00:00")) { args[1] = "24:00:00"; } if (end < start) { if (now >= end && now <= start) { return false; } else { return true; } } else { if (now >= start && now <= end) { return true; } else { return false; } } } catch (ParseException e) { e.printStackTrace(); throw new IllegalArgumentException("Illegal Argument arg:" + sourceTime); } }
阅读全文
0 0
- 时分秒时间段的区域判断
- ERLANG判断时间,时分秒
- 输入年月日时分秒,输出年月日时分秒的下一秒
- 输入年月日时分秒,计算下一秒的年月日时分秒
- 年月日 时分秒的取得
- 年月日 时分秒的取得
- SimpleDateFormat的时分秒格式
- 求当前的时分秒
- 秒转为时分秒的oracle函数
- 时分秒
- 秒转时分秒
- 秒转为时分秒
- 年月日时分秒的即时显示
- 自己的AnalogClock 指针 时分秒
- 带有年月日时分秒的时间控件
- 将秒数转换成天时分秒的格式
- 输出年月日时分秒的小程序
- 取时间的年月日时分秒
- CSS样式(块级元素、行内元素、行内块级元素以及转换)
- mybatis 获得插入操作之后的自增主键
- tp 的 mysql的sql_mode
- 关于字符串数组,字符串指针(C语言)
- android 5.0以上版本控件点击 水波纹效果
- 时分秒时间段的区域判断
- JSP动态导入与静态导入
- ajax嵌套解决
- 服务器之如何更好的是使用开发缓存
- 欢迎使用CSDN-markdown编辑器
- android之ImageView显示超长大图模糊的问题
- DataSet更新到数据库
- 欢迎使用CSDN-markdown编辑器
- IOPS