90601e4f
黄灿宏
标准版本 1.扩展设备10 增...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
package com.ectrip.cyt.utils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Created by dc on 2018/6/28.
* 时间工具类
*/
public class TimesUtils {
private static long lastTime = 0;
public static boolean over1s(long overTime) {
long nowTime = System.currentTimeMillis();
if (nowTime - lastTime < overTime) {
return true;
}
lastTime = nowTime;
return false;
}
private static long lastSountTime = 0;
public static boolean overTimes(long overTime) {
long nowTime = System.currentTimeMillis();
if (nowTime - lastSountTime > overTime) {
lastSountTime = nowTime;
return true;
}
return false;
}
/**
* 最后一次扫描到人脸的时间
*/
private static long lastScanTime = 0;
public static void setLastScanTime() {
lastScanTime = System.currentTimeMillis();
}
public static boolean overScanTimes(long overTime) {
long nowTime = System.currentTimeMillis();
if (nowTime - lastScanTime > overTime) {
lastScanTime = nowTime;
return true;
}
return false;
}
private static long lastFaceTime = 0;
public static boolean overFaceTimes(long overTime) {
long nowTime = System.currentTimeMillis();
if (nowTime - lastFaceTime > overTime) {
lastFaceTime = nowTime;
return true;
}
return false;
}
public static int getAge(String scanTicketId) {
try {
String year = scanTicketId.substring(6, 10);
String mony = scanTicketId.substring(10, 12);
String day = scanTicketId.substring(12, 14);
String brithday = year + "-" + mony + "-" + day;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return getAgeth(sdf.parse(brithday));
} catch (Exception e) {
LogUtil.d("timeUtils", e.getMessage());
}
return 0;
}
//由出生日期获得年龄
public static int getAgeth(Date birthDay) throws Exception {
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) {
throw new IllegalArgumentException(
"The birthDay is before Now.It's unbelievable!");
}
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR);
int monthBirth = cal.get(Calendar.MONTH);
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
int age = yearNow - yearBirth;
if (monthNow <= monthBirth) {
if (monthNow == monthBirth) {
if (dayOfMonthNow < dayOfMonthBirth) age--;
} else {
age--;
}
}
return age;
}
}
|