From 2bd2f4415fe1f5e3b21df3e55d1fee66dcf66e16 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Fri, 12 Jun 2026 17:00:20 +0900 Subject: [PATCH] =?UTF-8?q?260612=5F05=5FENH:=20=EC=97=91=EC=85=80=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=20=EA=B0=92=20=EC=9D=BD=EB=8A=94=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=ED=8F=AC=EB=A7=B7=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../com/kri/common/feature/excel/ExcelUtil.java | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index bb959b1..556fa3f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } // 버전 변경은 여기서 -def commonVer = "beta.1.1.28" +def commonVer = "beta.1.1.29" group = 'com.kri.common' version = commonVer diff --git a/src/main/java/com/kri/common/feature/excel/ExcelUtil.java b/src/main/java/com/kri/common/feature/excel/ExcelUtil.java index a7f47ff..3ac3c9a 100644 --- a/src/main/java/com/kri/common/feature/excel/ExcelUtil.java +++ b/src/main/java/com/kri/common/feature/excel/ExcelUtil.java @@ -1,5 +1,6 @@ package com.kri.common.feature.excel; +import java.text.SimpleDateFormat; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; @@ -10,6 +11,10 @@ import org.apache.poi.ss.util.NumberToTextConverter; public final class ExcelUtil { + private static final double TIME_FRACTION_EPSILON = 0.0000001; + private static final String DATE_FORMAT = "yyyy-MM-dd"; + private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; + private ExcelUtil() { } @@ -76,13 +81,15 @@ public final class ExcelUtil { private static String formatNumericCell(Cell cell, double value, DataFormatter formatter) { if (DateUtil.isCellDateFormatted(cell)) { - return formatter.formatRawCellContents( - value, - cell.getCellStyle().getDataFormat(), - cell.getCellStyle().getDataFormatString() - ); + String pattern = hasTimeFraction(value) ? DATE_TIME_FORMAT : DATE_FORMAT; + return new SimpleDateFormat(pattern).format(DateUtil.getJavaDate(value)); } return NumberToTextConverter.toText(value); } + + private static boolean hasTimeFraction(double value) { + double fraction = value - Math.floor(value); + return fraction > TIME_FRACTION_EPSILON && (1 - fraction) > TIME_FRACTION_EPSILON; + } }