android 判断时间是否已过期
2017-12-09 11:09
1146 查看
public static boolean IsToday(String day) throws ParseException { // 当前的时刻 Calendar pre = Calendar.getInstance(); Date predate = new Date(System.currentTimeMillis()); pre.setTime(predate); // 设定的时刻 Calendar cal = Calendar.getInstance(); Date date = sdf.parse(day); cal.setTime(date); if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) { int diffDay = cal.get(Calendar.DAY_OF_YEAR) - pre.get(Calendar.DAY_OF_YEAR); int diffHour = cal.get(Calendar.HOUR_OF_DAY) - pre.get(Calendar.HOUR_OF_DAY); int diffMin = cal.get(Calendar.MINUTE) - pre.get(Calendar.MINUTE); if (diffDay == 0) { if (diffHour == 0) { if (diffMin >= 0) { return true; } } else if (diffHour > 0) { return true; } } else if (diffDay > 0) { return true; } } else if (cal.get(Calendar.YEAR) > (pre.get(Calendar.YEAR))) { return true; } return false; } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); cur_time.setText(sdf.format(new Date()));// 开会时间
相关文章推荐
- android 判断时间是否已过期
- Android之判断时间是否为今天
- Android 判断获取的时间是否是今天、昨天
- js判断时间是否过期
- Android 获取当前系统时间 时间之间的转换 判断字符串是否日日期类型
- android 字符串工具类 格式化日期字符串 拼接数组 判断字符串是否为空 转换时间显示 转换文件大小 获取中英文字符个数
- Android如何判断时间是否在0到8点之间
- 判断手机号格式是否正确(写于2015年,过期时间未知)
- Js添加、读取、删除cookie,判断cookie是否有效,指定domain域下主路径path下设置cookie,设置expires过期时间
- android 判断是否真正连接到internet(通过检测网址,需要时间)
- Android之判断时间是否为今天
- android 根据时间是否过期进行文件的删除
- 在Android设备上判断设备是否支持摄像头
- android判断phonegap是否联网且加载super.loadUrl网址【转】
- Android 判断是否连接网络
- android 开发录音那些事(录音权限授权及判断录音权限是否拒绝处理)
- android 判断view 是否被遮挡
- Android判断应用是否在前台或后台
- android判断手机是否联网
- Android判断应用或Activity是否存在