in core/src/main/java/com/alibaba/fastjson2/util/DateUtils.java [5501:5723]
public static long parseMillisYMDHMS19(String str, ZoneId zoneId) {
if (str == null) {
return 0;
}
char c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18;
if (JVM_VERSION == 8) {
char[] chars = JDKUtils.getCharArray(str);
if (chars.length != 19) {
throw new DateTimeParseException("illegal input " + str, str, 0);
}
c0 = chars[0];
c1 = chars[1];
c2 = chars[2];
c3 = chars[3];
c4 = chars[4];
c5 = chars[5];
c6 = chars[6];
c7 = chars[7];
c8 = chars[8];
c9 = chars[9];
c10 = chars[10];
c11 = chars[11];
c12 = chars[12];
c13 = chars[13];
c14 = chars[14];
c15 = chars[15];
c16 = chars[16];
c17 = chars[17];
c18 = chars[18];
} else if (STRING_CODER != null
&& STRING_CODER.applyAsInt(str) == 0
&& STRING_VALUE != null
) {
byte[] bytes = JDKUtils.STRING_VALUE.apply(str);
if (bytes.length != 19) {
throw new DateTimeParseException("illegal input " + str, str, 0);
}
c0 = (char) bytes[0];
c1 = (char) bytes[1];
c2 = (char) bytes[2];
c3 = (char) bytes[3];
c4 = (char) bytes[4];
c5 = (char) bytes[5];
c6 = (char) bytes[6];
c7 = (char) bytes[7];
c8 = (char) bytes[8];
c9 = (char) bytes[9];
c10 = (char) bytes[10];
c11 = (char) bytes[11];
c12 = (char) bytes[12];
c13 = (char) bytes[13];
c14 = (char) bytes[14];
c15 = (char) bytes[15];
c16 = (char) bytes[16];
c17 = (char) bytes[17];
c18 = (char) bytes[18];
} else {
if (str.length() != 19) {
throw new DateTimeParseException("illegal input " + str, str, 0);
}
c0 = str.charAt(0);
c1 = str.charAt(1);
c2 = str.charAt(2);
c3 = str.charAt(3);
c4 = str.charAt(4);
c5 = str.charAt(5);
c6 = str.charAt(6);
c7 = str.charAt(7);
c8 = str.charAt(8);
c9 = str.charAt(9);
c10 = str.charAt(10);
c11 = str.charAt(11);
c12 = str.charAt(12);
c13 = str.charAt(13);
c14 = str.charAt(14);
c15 = str.charAt(15);
c16 = str.charAt(16);
c17 = str.charAt(17);
c18 = str.charAt(18);
}
if (c4 != '-' || c7 != '-' || c10 != ' ' || c13 != ':' || c16 != ':') {
throw new DateTimeParseException("illegal input", str, 0);
}
char y0 = c0;
char y1 = c1;
char y2 = c2;
char y3 = c3;
char m0 = c5;
char m1 = c6;
char d0 = c8;
char d1 = c9;
char h0 = c11;
char h1 = c12;
char i0 = c14;
char i1 = c15;
char s0 = c17;
char s1 = c18;
int year;
if (y0 >= '0' && y0 <= '9'
&& y1 >= '0' && y1 <= '9'
&& y2 >= '0' && y2 <= '9'
&& y3 >= '0' && y3 <= '9'
) {
year = (y0 - '0') * 1000 + (y1 - '0') * 100 + (y2 - '0') * 10 + (y3 - '0');
} else {
throw new DateTimeParseException("illegal input", str, 0);
}
int month;
if (m0 >= '0' && m0 <= '9'
&& m1 >= '0' && m1 <= '9'
) {
month = (m0 - '0') * 10 + (m1 - '0');
if ((month == 0 && year != 0) || month > 12) {
throw new DateTimeParseException("illegal input", str, 0);
}
} else {
throw new DateTimeParseException("illegal input", str, 0);
}
int dom;
if (d0 >= '0' && d0 <= '9'
&& d1 >= '0' && d1 <= '9'
) {
dom = (d0 - '0') * 10 + (d1 - '0');
int max = 31;
switch (month) {
case 2:
boolean leapYear = (year & 3) == 0 && ((year % 100) != 0 || (year % 400) == 0);
max = leapYear ? 29 : 28;
break;
case 4:
case 6:
case 9:
case 11:
max = 30;
break;
}
if ((dom == 0 && year != 0) || dom > max) {
throw new DateTimeParseException("illegal input", str, 0);
}
} else {
throw new DateTimeParseException("illegal input", str, 0);
}
int hour;
if (h0 >= '0' && h0 <= '9'
&& h1 >= '0' && h1 <= '9'
) {
hour = (h0 - '0') * 10 + (h1 - '0');
} else {
throw new DateTimeParseException("illegal input", str, 0);
}
int minute;
if (i0 >= '0' && i0 <= '9'
&& i1 >= '0' && i1 <= '9'
) {
minute = (i0 - '0') * 10 + (i1 - '0');
} else {
throw new DateTimeParseException("illegal input", str, 0);
}
int second;
if (s0 >= '0' && s0 <= '9'
&& s1 >= '0' && s1 <= '9'
) {
second = (s0 - '0') * 10 + (s1 - '0');
} else {
throw new DateTimeParseException("illegal input", str, 0);
}
if (year == 0 && month == 0 && dom == 0) {
year = 1970;
month = 1;
dom = 1;
}
long utcSeconds;
{
long epochDay = calcEpochDay(year, month, dom);
utcSeconds = epochDay * 86400
+ hour * 3600
+ minute * 60
+ second;
}
int zoneOffsetTotalSeconds;
if (zoneId == null) {
zoneId = DEFAULT_ZONE_ID;
}
boolean shanghai = zoneId == SHANGHAI_ZONE_ID || zoneId.getRules() == SHANGHAI_ZONE_RULES;
long SECONDS_1991_09_15_02 = 684900000; // utcMillis(1991, 9, 15, 2, 0, 0);
if (shanghai && utcSeconds >= SECONDS_1991_09_15_02) {
zoneOffsetTotalSeconds = 28800; // OFFSET_0800_TOTAL_SECONDS
} else if (zoneId == ZoneOffset.UTC || "UTC".equals(zoneId.getId())) {
zoneOffsetTotalSeconds = 0;
} else {
LocalDate localDate = LocalDate.of(year, month, dom);
LocalTime localTime = LocalTime.of(hour, minute, second, 0);
LocalDateTime ldt = LocalDateTime.of(localDate, localTime);
ZoneOffset offset = zoneId.getRules().getOffset(ldt);
zoneOffsetTotalSeconds = offset.getTotalSeconds();
}
return (utcSeconds - zoneOffsetTotalSeconds) * 1000L;
}