Created
June 10, 2015 18:22
-
-
Save eirikbakke/af72fed74ed7a4d6272b to your computer and use it in GitHub Desktop.
Example Jackcess patch to handle negative dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double adjustNegativeDatesFromAccess(double value) { | |
double fractionalPart = value % 1.0; // Negative if value is negative. | |
double wholePart = value - fractionalPart; | |
return wholePart + Math.abs(fractionalPart); | |
} | |
// Simplified equivalent implementation (avoids touching positive dates). | |
private double adjustNegativeDatesFromAccess2(double value) { | |
return value >= 0.0 ? value : (value - 2.0 * (value % 1.0)); | |
} | |
public long fromDateDouble(double value) { | |
long time = Math.round(adjustNegativeDatesFromAccess2(value) * MILLISECONDS_PER_DAY); | |
time -= MILLIS_BETWEEN_EPOCH_AND_1900; | |
time -= getFromLocalTimeZoneOffset(time); | |
return time; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment