Skip to content

Commit 2e4b720

Browse files
committed
Correction of bug when number of nano seconds equals a full day
1 parent 86b07de commit 2e4b720

File tree

1 file changed

+5
-0
lines changed
  • fastexcel-reader/src/main/java/org/dhatim/fastexcel/reader

1 file changed

+5
-0
lines changed

fastexcel-reader/src/main/java/org/dhatim/fastexcel/reader/Cell.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public LocalDateTime asDate() {
9999
private LocalDateTime convertToDate(double value) {
100100
int wholeDays = (int) Math.floor(value);
101101
long millisecondsInDay = (long) (((value - wholeDays) * DAY_MILLISECONDS) + 0.5D);
102+
// sometimes the rounding for .9999999 returns the whole number of ms a day
103+
if(millisecondsInDay == DAY_MILLISECONDS) {
104+
wholeDays +=1;
105+
millisecondsInDay= 0;
106+
}
102107

103108
int startYear = 1900;
104109
int dayAdjust = -1; // Excel thinks 2/29/1900 is a valid date, which it isn't

0 commit comments

Comments
 (0)