Commit 5bf34d81 by fudahua

feat:时间格式

parent efc6d1bd
...@@ -25,12 +25,11 @@ import org.apache.commons.lang.time.DateUtils; ...@@ -25,12 +25,11 @@ import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat; import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -973,10 +972,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -973,10 +972,9 @@ 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());
} }
HSSFWorkbook demoWorkBook = new HSSFWorkbook(); CellStyle cellStyle = wb.createCellStyle();
HSSFCellStyle dateStyle = demoWorkBook.createCellStyle(); DataFormat dataFormat = wb.createDataFormat();
HSSFDataFormat format= demoWorkBook.createDataFormat(); cellStyle.setDataFormat(dataFormat.getFormat("yyyy/MM/dd HH:mm:ss"));
dateStyle.setDataFormat(format.getFormat("yyyy/MM/dd HH:mm:ss"));
// 遍历输出行 // 遍历输出行
...@@ -989,10 +987,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -989,10 +987,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
Integer type = columnMate.get(j).getValue(); Integer type = columnMate.get(j).getValue();
Cell midCell = row.createCell(j); Cell midCell = row.createCell(j);
switch (type) { switch (type) {
case Types.DATE:
case Types.TIMESTAMP: case Types.TIMESTAMP:
case Types.TIME: midCell.setCellStyle(cellStyle);
midCell.setCellStyle(dateStyle);
} }
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