-
Notifications
You must be signed in to change notification settings - Fork 14
/
utils.pde
77 lines (67 loc) · 2 KB
/
utils.pde
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
String mydate(int offset)
{
Date d = new Date();
long timestamp = d.getTime() + (86400000 * offset);
String date = new java.text.SimpleDateFormat("yyyyMMdd").format(timestamp);
return date;
}
String today()
{
return mydate(0);
}
String mytime()
{ Date d = new Date();
long timestamp = d.getTime();
String date = new java.text.SimpleDateFormat("HHmmss").format(timestamp);
return date;
}
String datetimefile()
{ Date d = new Date();
long timestamp = d.getTime();
String date = new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(timestamp);
return date;
}
String datetime()
{ Date d = new Date();
long timestamp = d.getTime();
String date = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(timestamp);
return date;
}
void printDataDigest(byte[] arr) {
int digestStartLength = 5;
int digestEndLength = 5;
int digestStartEndIndex = min(arr.length, digestStartLength);
int digestEndStartIndex = arr.length-(digestEndLength+HEADER_SIZE);
StringBuilder sb = new StringBuilder();
for (int i=0; i<digestStartEndIndex; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
if (digestEndStartIndex>=0 && digestEndStartIndex>digestStartEndIndex) {
sb.append("..., ");
for (int i=digestEndStartIndex; i<arr.length; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
}
println(sb.toString());
}
void printDataDigest(int[] arr) {
int digestStartLength = 5;
int digestEndLength = 5;
int digestStartEndIndex = min(arr.length, digestStartLength);
int digestEndStartIndex = arr.length-(digestEndLength+HEADER_SIZE);
StringBuilder sb = new StringBuilder();
for (int i=0; i<digestStartEndIndex; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
if (digestEndStartIndex>=0 && digestEndStartIndex>digestStartEndIndex) {
sb.append("..., ");
for (int i=digestEndStartIndex; i<arr.length; i++) {
sb.append(String.valueOf(arr[i]));
sb.append(",");
}
}
println(sb.toString());
}