java判断两个时间是不是同一天的方法
时间:2022-09-23 03:09:16
public class TimeUtil {
public static final int SECONDS_IN_DAY = 60 * 60 * 24;
public static final long MILLIS_IN_DAY = 1000L * SECONDS_IN_DAY;
public static boolean isSameDayOfMillis(final long ms1, final long ms2) {
final long interval = ms1 - ms2;
return interval < MILLIS_IN_DAY
&& interval > -1L * MILLIS_IN_DAY
&& toDay(ms1) == toDay(ms2);
}
private static long toDay(long millis) {
return (millis + TimeZone.getDefault().getOffset(millis)) / MILLIS_IN_DAY;
}
}
标签:java,时间
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#实现排列组合算法完整实例
2023-04-16 09:36:59
基于Silverlight DataGrid中无代码设置开始与结束日期DatePicker的实现方法
2023-05-04 16:34:50
![](https://img.aspxhome.com/file/2023/8/129658_0s.gif)
C#多线程学习之(五)使用定时器进行多线程的自动管理
2022-03-05 13:55:44
Android实现悬浮窗体效果
2023-03-12 01:04:02
![](https://img.aspxhome.com/file/2023/8/111738_0s.gif)
C#中读写INI配置文件的方法
2021-10-29 19:57:37
高效C#编码优化原则
2023-06-13 03:16:23
Java接口和抽象类有什么区别
2021-08-21 07:01:18
java生成xml格式文件的方法
2023-11-23 02:40:32
![](https://img.aspxhome.com/file/2023/0/71660_0s.png)
应用启动数据初始化接口CommandLineRunner和Application详解
2023-02-06 05:00:33
![](https://img.aspxhome.com/file/2023/8/65608_0s.jpg)
Android动态布局小结
2021-10-17 12:04:39
spring-cloud-gateway动态路由的实现方法
2021-07-25 15:24:37
Spring Boot利用JSR303实现参数验证的方法实例
2022-07-28 20:36:26
![](https://img.aspxhome.com/file/2023/3/62533_0s.jpg)
Unity3D实现甜品消消乐游戏
2022-11-06 16:26:24
![](https://img.aspxhome.com/file/2023/0/83250_0s.gif)
android 自定义控件 自定义属性详细介绍
2022-08-05 12:19:41
深入理解Spring中bean的生命周期介绍
2023-02-08 17:21:37
![](https://img.aspxhome.com/file/2023/8/61318_0s.png)
解决IDEA鼠标点击光标变大问题
2022-12-07 11:52:37
![](https://img.aspxhome.com/file/2023/4/79964_0s.jpg)
SpringBoot利用拦截器实现避免重复请求
2022-02-07 00:21:53
![](https://img.aspxhome.com/file/2023/1/68021_0s.png)
Android加载loading对话框的功能及实例代码(不退出沉浸式效果)
2023-05-14 01:25:33
![](https://img.aspxhome.com/file/2023/3/118923_0s.gif)
利用Java连接Hadoop进行编程
2022-11-12 09:02:12
![](https://img.aspxhome.com/file/2023/5/77095_0s.png)
浅谈C# StringBuilder内存碎片对性能的影响
2023-12-15 08:55:47