MCPcopy Index your code
hub / github.com/Bit0r/java-util / decimal

Method decimal

src/main/java/util/ExcelUtils.java:183–201  ·  view source on GitHub ↗

小数长度 @param v 值 @param excelCheck 注解 @param i 行数 @param fieldName excel段名 @param errList 错误信息集合

(Object v, ExcelCheck excelCheck, int i, String fieldName, List<String> errList)

Source from the content-addressed store, hash-verified

181 * @param errList 错误信息集合
182 */
183 private static void decimal(Object v, ExcelCheck excelCheck, int i, String fieldName, List<String> errList) {
184 if (excelCheck.decimal() != -1 && ObjectUtil.isNotEmpty(v)) {
185 if (isNumeric(v.toString())) {
186 //去除小数末位的0
187 BigDecimal value = new BigDecimal(v.toString());
188 BigDecimal noZeros = value.stripTrailingZeros();
189 String data = noZeros.toPlainString();
190 String[] strs = data.split("\\.");
191 if (strs.length > 1 && strs[1].length() > excelCheck.decimal()) {
192 StringBuilder err = new StringBuilder("第").append(i).append("行,").append(fieldName).append("小数长度超过").append(excelCheck.decimal()).append("位;");
193 errList.add(err.toString());
194 }
195 } else {
196 StringBuilder err = new StringBuilder("第").append(i).append("行,").append(fieldName).append("不是数值;");
197 errList.add(err.toString());
198 }
199 }
200
201 }
202
203 /**
204 * 整数长度

Callers 1

excelCheckObjMethod · 0.95

Calls 1

isNumericMethod · 0.95

Tested by

no test coverage detected