### Question:
StringUtil { public static String col2string(Object column, String type) { if(column == null){ return ""; } if(type == null){ return column.toString(); } String rowData = column.toString(); ColumnType columnType = ColumnType.getType(type.toUpperCase()); Object result; switch (columnType) { case TINYINT: result = Byte.valueOf(rowData.trim()); break; case SMALLINT: case SHORT: result = Short.valueOf(rowData.trim()); break; case INT: case INTEGER: result = Integer.valueOf(rowData.trim()); break; case BIGINT: case LONG: if (column instanceof Timestamp){ result=((Timestamp) column).getTime(); }else { result = Long.valueOf(rowData.trim()); } break; case FLOAT: result = Float.valueOf(rowData.trim()); break; case DOUBLE: result = Double.valueOf(rowData.trim()); break; case DECIMAL: result = new BigDecimal(rowData.trim()); break; case STRING: case VARCHAR: case CHAR: case TEXT: if (column instanceof Timestamp){ result = DateUtil.timestampToString((java.util.Date)column); }else { result = rowData; } break; case BOOLEAN: result = Boolean.valueOf(rowData.trim()); break; case DATE: result = DateUtil.dateToString(DateUtil.columnToDate(column, null)); break; case DATETIME: case TIMESTAMP: result = DateUtil.timestampToString(DateUtil.columnToTimestamp(column, null)); break; default: result = rowData; } return result.toString(); }  static String convertRegularExpr(String str); static Object string2col(String str, String type, SimpleDateFormat customTimeFormat); static String col2string(Object column, String type); static String row2string(Row row, List<String> columnTypes, String delimiter); static byte[] hexStringToByteArray(String hexString); static final int STEP_SIZE; }### Answer:
@Test public void testCol2string() { String result = StringUtil.col2string(null, null); Assert.assertEquals(result, ""); result = StringUtil.col2string("test", null); Assert.assertEquals(result, "test"); result = StringUtil.col2string(Byte.valueOf("1"), "TINYINT"); Assert.assertEquals(result, "1"); result = StringUtil.col2string(Short.valueOf("1"), "SMALLINT"); Assert.assertEquals(result, "1"); result = StringUtil.col2string(123, "INTEGER"); Assert.assertEquals(result, "123"); result = StringUtil.col2string(123L, "LONG"); Assert.assertEquals(result, "123"); result = StringUtil.col2string(new Timestamp(1584510286187L), "LONG"); Assert.assertEquals(result, "1584510286187"); result = StringUtil.col2string(123.123, "FLOAT"); Assert.assertEquals(result, "123.123"); result = StringUtil.col2string(123.123, "DOUBLE"); Assert.assertEquals(result, "123.123"); result = StringUtil.col2string(123.123, "DECIMAL"); Assert.assertEquals(result, "123.123"); result = StringUtil.col2string("string", "STRING"); Assert.assertEquals(result, "string"); result = StringUtil.col2string(new Timestamp(1584510286187L), "STRING"); Assert.assertEquals(result, "2020-03-18 13:44:46"); result = StringUtil.col2string(true, "BOOLEAN"); Assert.assertEquals(result, "true"); result = StringUtil.col2string(new Date(1584510286187L), "DATE"); Assert.assertEquals(result, "2020-03-18"); result = StringUtil.col2string(new Date(1584510286187L), "DATETIME"); Assert.assertEquals(result, "2020-03-18 13:44:46"); }