ISODate.java
2.67 KB
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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.ut;
import com.adobe.xfa.ut.DateTimeUtil;
import com.adobe.xfa.ut.LcDate;
public final class ISODate
extends LcDate {
public ISODate() {
super("en_US", 30);
}
public ISODate(int days) {
super(days, "en_US", 30);
}
public ISODate(String date, String locale) {
super(locale, 30);
String trimDate = date;
int tee = date.indexOf(84);
if (tee >= 0) {
trimDate = date.substring(0, tee);
}
trimDate = trimDate.trim();
this.mCenturySplit = 30;
this.setDateSymbols("en_US");
if (this.parse(trimDate)) {
this.mYearOfEra -= 1900;
this.mDays = this.mDayOfMonth < 0 || this.mMonthOfYear < 0 || this.mYearOfEra < 0 ? 0 : this.epoch(this.mDayOfMonth, this.mMonthOfYear, this.mYearOfEra);
} else {
this.mDays = 0;
}
this.setDateSymbols(locale);
this.mValid = this.mDays > 0;
}
public ISODate(String locale, int centurySplit) {
super(locale, centurySplit);
}
boolean parse(String src) {
boolean needDashes = src.indexOf(45) >= 0;
int srcPos = 0;
int srcLen = src.length();
this.mYearOfEra = -1;
this.mMonthOfYear = -1;
this.mDayOfYear = -1;
this.mDayOfMonth = -1;
this.mDayOfWeek = -1;
if (srcPos + 4 > srcLen) {
return false;
}
int parseRes = this.subParse(src, srcPos, 'Y', 4);
if (parseRes < 0) {
return false;
}
srcPos = parseRes;
if (srcPos == srcLen) {
this.mMonthOfYear = 1;
this.mDayOfMonth = 1;
return true;
}
if (needDashes) {
if (!DateTimeUtil.matchChr(src, srcPos, '-', false)) {
return false;
}
++srcPos;
}
if (srcPos + 2 > srcLen) {
return false;
}
parseRes = this.subParse(src, srcPos, 'M', 2);
if (parseRes < 0) {
return false;
}
srcPos = parseRes;
if (srcPos == srcLen) {
this.mDayOfMonth = 1;
return true;
}
if (needDashes) {
if (!DateTimeUtil.matchChr(src, srcPos, '-', false)) {
return false;
}
++srcPos;
}
if (srcPos + 2 > srcLen) {
return false;
}
parseRes = this.subParse(src, srcPos, 'D', 2);
if (parseRes < 0) {
return false;
}
srcPos = parseRes;
if (srcPos != srcLen) {
return false;
}
return true;
}
}