Commit 9970bd39 by fudahua

feat:时间格式

parent 830f72f6
...@@ -972,9 +972,13 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -972,9 +972,13 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
cell = row.createCell(j); cell = row.createCell(j);
cell.setCellValue(columnMate.get(j).getKey()); cell.setCellValue(columnMate.get(j).getKey());
} }
CellStyle cellStyle = wb.createCellStyle(); CellStyle yyyyMMddhhmmss = wb.createCellStyle();
DataFormat dataFormat = wb.createDataFormat(); DataFormat dataFormat = wb.createDataFormat();
cellStyle.setDataFormat(dataFormat.getFormat("yyyy-MM-dd HH:mm:ss")); yyyyMMddhhmmss.setDataFormat(dataFormat.getFormat("yyyy-MM-dd HH:mm:ss"));
CellStyle yyyyMMdd = wb.createCellStyle();
DataFormat yyyyMMddDataFormat = wb.createDataFormat();
yyyyMMdd.setDataFormat(yyyyMMddDataFormat.getFormat("yyyy-MM-dd HH:mm:ss"));
// 遍历输出行 // 遍历输出行
...@@ -986,10 +990,27 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -986,10 +990,27 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
for(int j=0; j<columnValues.length; j++){ for(int j=0; j<columnValues.length; j++){
Integer type = columnMate.get(j).getValue(); Integer type = columnMate.get(j).getValue();
Cell midCell = row.createCell(j); Cell midCell = row.createCell(j);
String columnValue = columnValues[j];
switch (type) { switch (type) {
case Types.DATE:
midCell.setCellStyle(yyyyMMdd);
midCell.setCellValue(DateUtils.parseDate(columnValue,new String[]{"yyyy-MM-dd"}));
break;
case Types.TIMESTAMP: case Types.TIMESTAMP:
midCell.setCellStyle(cellStyle); midCell.setCellStyle(yyyyMMddhhmmss);
midCell.setCellValue(DateUtils.parseDate(columnValues[j],new String[]{"yyyy-MM-dd hh:mm:ss"})); midCell.setCellValue(DateUtils.parseDate(columnValue,new String[]{"yyyy-MM-dd hh:mm:ss"}));
break;
case Types.INTEGER:
midCell.setCellValue(Integer.valueOf(columnValue));
break;
case Types.BIGINT:
midCell.setCellValue(Long.valueOf(columnValue));
break;
case Types.DOUBLE:
midCell.setCellValue(Double.valueOf(columnValue));
break;
case Types.FLOAT:
midCell.setCellValue(Float.valueOf(columnValue));
break; break;
default: default:
midCell.setCellValue(columnValues[j]); midCell.setCellValue(columnValues[j]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment