android 判断时间段,java,android:判断当前时间是否属于该时间段

java,android:判断当前时间是否属于该时间段

2020年12月04日

| 萬仟网IT编程

 | a48e1d17a2b0511faa7da7240b1971f6.png我要评论

自己写的一方法 /** * judge the current time is on the time, for example: current is 11:00, startTimeStringFormat=10:00,endTimeStringFormat==12:00,you will get true * * @param startTimeStringFormat String:"HH:mm" you must follow the format

自己写的一方法

/**

* judge the current time is on the time, for example: current is 11:00, startTimeStringFormat=10:00,endTimeStringFormat==12:00,you will get true

*

* @param startTimeStringFormat String:"HH:mm" you must follow the format

* @param endTimeStringFormat String:"HH:mm" you must follow the format

* @return boolean: if the the current time on the range

* @throws Exception : simpleDateFormat.parse maybe null, simpleDateFormat.parse mayby exception

*/

public static boolean currentTimebelongTheRange(String startTimeStringFormat, String endTimeStringFormat) throws Exception {

String dateFormatString = "HH:mm";

SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatString);

//first get now time calendar

String nowTimeFormat = simpleDateFormat.format(new Date());

Date nowTimeData = simpleDateFormat.parse(nowTimeFormat);

Calendar nowTimeCalendar = Calendar.getInstance();

nowTimeCalendar.setTime(Objects.requireNonNull(nowTimeData));

//second get start time calendar

Date startTimeData = simpleDateFormat.parse(startTimeStringFormat);

Calendar startTimeCalendar = Calendar.getInstance();

startTimeCalendar.setTime(Objects.requireNonNull(startTimeData));

//third get end time calendar

Date endTimeData = simpleDateFormat.parse(endTimeStringFormat);

Calendar endTimeCalendar = Calendar.getInstance();

endTimeCalendar.setTime(Objects.requireNonNull(endTimeData));

return nowTimeCalendar.after(startTimeCalendar) && nowTimeCalendar.before(endTimeCalendar);

}

本文地址:https://blog.csdn.net/qq_36017059/article/details/110631471

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。

如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

相关文章:

COOKIE与SESSION 1,基本概念 cookie机制采用的是在客户端保持状态的方案,当你在浏览网站的时候,cookie是一个文本信息,会帮你...

public class SwitchCase { public static void main(String[] args) { System....

gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg

1.新建一个springboot工程2.需要导入mybatis和mybatis-plus的依赖文件

gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg

这一篇目的就是在于网页爬虫的实现,对数据的获取,以便分析。

目录:

1、爬虫原理

2、本地文件数据提取及分析

3、单...

gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg

其实很多读者都在关注微服务层是如何设计的,其中包括微服务架构、规则流程、定义标准,其实本篇文章不想过多的重复介绍...

java 实现计数排序和桶排序实例代码

目录

比较和非比较的区别

常见的快速排序、归并排序、堆排序、冒泡排序等属于比较排序。在...

本文实例讲述了java简单数组排序(冒泡法)。分享给大家供大家参考,具体如下:

import java.util.scan...

public static String entityToUrlParam(T t){ ...

1,前言有关@ComponentScan的Filter属性的记录2,Filter@ComponentScan中还...

网友评论

387afa1e91d68b43eca6c11dc07bf577.gif

验证码:

744752.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值