Skip to content

Instantly share code, notes, and snippets.

@eirikbakke
Created June 10, 2015 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eirikbakke/af72fed74ed7a4d6272b to your computer and use it in GitHub Desktop.
Save eirikbakke/af72fed74ed7a4d6272b to your computer and use it in GitHub Desktop.
Example Jackcess patch to handle negative dates
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