in src/main/java/com/aliyun/dts/subscribe/clients/record/value/DateTime.java [624:720]
protected void parseJdbcDatetime(String datetime) {
if (null == datetime || datetime.trim().isEmpty()) {
throw new IllegalArgumentException("datetime is null or empty.");
}
if (isSet(SEG_COMMON_ERA) && datetime.length() > 2) {
String commonEra = datetime.substring(datetime.length() - 2);
if (commonEraNames.contains(commonEra)) {
this.setCommonEra(commonEra);
datetime = datetime.substring(0, datetime.length() - 2).trim();
}
}
if (isSet(SEG_TIMEZONE)) {
int index = -1;
for (int i = datetime.length() - 1; i >= 0; --i) {
char c = datetime.charAt(i);
if (' ' == c || '+' == c || '-' == c) {
if (i > 1) {
char lc = datetime.charAt(i - 1);
if ((lc >= 'a' && lc <= 'z') || (lc >= 'A' && lc <= 'Z')) {
continue;
}
}
index = i;
break;
}
}
if (index >= 0) {
String rawTimeZone = datetime.substring(index);
Triple<Boolean, StringBuilder, StringBuilder> normalizedTimeZone = validateAndConvertTimeZone(rawTimeZone.trim());
if (normalizedTimeZone.getLeft()) {
this.timeOffset = normalizedTimeZone.getMiddle().toString();
this.timeZone = normalizedTimeZone.getRight().toString();
datetime = datetime.substring(0, datetime.length() - rawTimeZone.length()).trim();
}
}
}
int[] ret = new int[7];
int j = 0, m = 0, n = 0;
byte[] bytes = datetime.getBytes();
boolean microMode = false;
for (int i = 0; i < bytes.length && j < bytes.length; ++i) {
if ('0' <= bytes[i] && '9' >= bytes[i]) {
m *= 10;
m += bytes[i] - '0';
n += 1;
} else if (0 != n) {
ret[j] = m;
if (microMode) {
ret[j] = upMicroToNaons(m, 9 - n);
}
m = 0;
n = 0;
++j;
if ('.' == bytes[i]) {
microMode = true;
} else {
microMode = false;
}
}
}
if (n != 0) {
ret[j] = m;
if (microMode) {
ret[j] = upMicroToNaons(m, 9 - n);
}
}
int index = 0;
if (isSet(SEG_YEAR)) {
this.setYear(ret[index++]);
}
if (isSet(SEG_MONTH)) {
this.setMonth(ret[index++]);
}
if (isSet(SEG_DAY)) {
this.setDay(ret[index++]);
}
if (isSet(SEG_HOUR)) {
this.setHour(ret[index++]);
}
if (isSet(SEG_MINITE)) {
this.setMinute(ret[index++]);
}
if (isSet(SEG_SECOND)) {
this.setSecond(ret[index++]);
}
if (isSet(SEG_NAONS)) {
this.setNaons(ret[index++]);
}
if ('-' == bytes[0]) {
setSegments(SEG_NEGATIVE);
}
}