package com.yida.data.device.convertor.telephone;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class DurationConvertor implements Converter<Integer> {
    @Override
    public Class supportJavaTypeKey() {
        return null;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public CellData<String> convertToExcelData(Integer value,
                                               ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        Integer minute = value / 60;
        Integer second = value % 60;
        StringBuilder builder = new StringBuilder();
        if (minute > 0) {
            builder.append(minute).append("分");
        }
        builder.append(second).append("秒");
        return new CellData<>(builder.toString());
    }
}
