All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.schoolwow.sdk.video.analyzer.AbstractAnalyzer Maven / Gradle / Ivy

package cn.schoolwow.sdk.video.analyzer;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public abstract class AbstractAnalyzer implements Analyzer {

    /**
     * 解析日期字符串
     *
     * @param dateString 日期字符串
     * @param pattern    日期模式
     */
    protected LocalDate parseDate(String dateString, String pattern) {
        LocalDate localDate = LocalDate.parse(dateString, DateTimeFormatter.ofPattern(pattern));
        return localDate;
    }

    /**
     * 根据时长格式化信息获取对应时长(秒)
     *
     * @param secondsFormat 时长(秒)格式化字符串
     */
    protected int getSeconds(String secondsFormat) {
        String[] tokens = secondsFormat.split(":");
        int seconds = 0;
        for (int i = 0; i < tokens.length; i++) {
            seconds += Integer.parseInt(tokens[i]) * Math.pow(60, tokens.length - 1 - i);
        }
        return seconds;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy