日期:2014-05-16 浏览次数:20484 次
static final Pattern pattern = Pattern.compile("[eE]"); private BigDecimal toBigDecimal(double cellValue) { String resultString = String.valueOf(cellValue); // 针对科学计数法的处理(对于小数位数精确到5位) if (pattern.matcher(resultString).find()) { DecimalFormat format = new DecimalFormat("#####.#####"); resultString = format.format(cellValue); } if (resultString.endsWith(".0")) { resultString = resultString.substring(0, resultString.length() - 2); } BigDecimal result = new BigDecimal(resultString); return result; }
// 由于dbunit对excel的时间处理会使用TimeZone.getOffset()做一个偏移转换, 这里需要设置一下 TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
public class TPreparedBatchStatement implements IPreparedBatchStatement { boolean notAllNull; // 所有参数是否为null boolean noParameter = true; // 是否指定参数 private int _index; ... public void close() throws SQLException { ... } public void addValue(Object value, DataType dataType) throws TypeCastException, SQLException { logger.debug("addValue(value={}, dataType={}) - start", value, dataType); noParameter = false; // Special NULL handling if (value == null || value == ITable.NO_VALUE) { _statement.setNull(++_index, dataType.getSqlType()); return; } notAllNull = true; dataType.setSqlValue(value, ++_index, _statement); } public void addBatch() throws SQLException { logger.debug("addBatch() - start"); // 没有参数, 或者有参数, 但是参数不全为null if (noParameter || (!noParameter && notAllNull)) { _statement.addBatch(); notAllNull = false; noParameter = true; } _index = 0; } ...
Column column = null; // 标识唯一键 byte underline = cell.getCellStyle().getFont(workbook).getUnderline(); if (underline == 1) { column = new Column(columnName, DataType.UNKNOWN, null, null, null, "unique", null); } else { column = new Column(columnName, DataType.UNKNOWN); } columnList.add(column);
public class DeleteByUniqueKeyOperation extends DatabaseOperation { pri