public long toEpochMilliSeconds()

in src/main/java/com/aliyun/dts/subscribe/clients/record/value/DateTime.java [256:289]


    public long toEpochMilliSeconds() throws ParseException {
        String parseTimeZone = getTimeOffset();
        SimpleDateFormat sdf = dateFormat.get();

        // construct sdf if needed
        if (null == sdf) {
            sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
            dateFormat.set(sdf);
        }

        String org = toJdbcString(DateTime.SEG_DATETIME_NAONS, false);
        String orgEndMilliSecond = StringUtils.substring(org, 0, org.length() - 6);

        if (null == parseTimeZone || parseTimeZone.trim().isEmpty()) {
            Date date = sdf.parse(orgEndMilliSecond);
            return date.getTime();
        }

        // "GMT+0:00" => "GMT+00:00"
        if (parseTimeZone.startsWith("GMT") && parseTimeZone.substring(3).length() == 5) {
            parseTimeZone = "GMT+0" + parseTimeZone.substring(4);
        }
        // "+0:00"=>"+00:00"
        if (parseTimeZone.length() == 5) {
            parseTimeZone = "+0" + parseTimeZone.substring(1);
        }
        ZoneId zoneId = ZoneId.of(parseTimeZone);
        TimeZone timeZone = TimeZone.getTimeZone(zoneId);
        if (sdf.getTimeZone() != timeZone) {
            sdf.setTimeZone(timeZone);
        }
        Date date = sdf.parse(orgEndMilliSecond);
        return date.getTime();
    }