LongStringConverter.java
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.taover.easyexcel.converters.longconverter;
import java.text.ParseException;
import com.taover.easyexcel.converters.Converter;
import com.taover.easyexcel.enums.CellDataTypeEnum;
import com.taover.easyexcel.metadata.CellData;
import com.taover.easyexcel.metadata.GlobalConfiguration;
import com.taover.easyexcel.metadata.property.ExcelContentProperty;
import com.taover.easyexcel.util.NumberUtils;
/**
* Long and string converter
*
* @author Jiaju Zhuang
*/
public class LongStringConverter implements Converter<Long> {
@Override
public Class supportJavaTypeKey() {
return Long.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseLong(cellData.getStringValue(), contentProperty);
}
@Override
public CellData convertToExcelData(Long value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellData(value, contentProperty);
}
}