Skip to content

Commit

Permalink
[CARBONDATA-671]Fixed Date issue when date is less the 1970 This closes
Browse files Browse the repository at this point in the history
  • Loading branch information
ravipesala committed Jan 20, 2017
2 parents b2eb9c7 + c33e5b2 commit 254af99
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*/
public class DateDirectDictionaryGenerator implements DirectDictionaryGenerator {

private static final int cutOffDate = Integer.MAX_VALUE >> 1;
private static final long SECONDS_PER_DAY = 60 * 60 * 24L;
private static final long MILLIS_PER_DAY = SECONDS_PER_DAY * 1000L;

Expand Down Expand Up @@ -131,7 +132,7 @@ private int getDirectSurrogateForMember(String memberStr) {
if (key == 1) {
return null;
}
return key;
return key - cutOffDate;
}

private int generateDirectSurrogateKeyForNonTimestampType(String memberStr) {
Expand All @@ -151,7 +152,7 @@ private int generateDirectSurrogateKeyForNonTimestampType(String memberStr) {

private int generateKey(long timeValue) {
long milli = timeValue + threadLocalLocalTimeZone.get().getOffset(timeValue);
int key = (int) Math.floor((double) milli / MILLIS_PER_DAY);
int key = (int) Math.floor((double) milli / MILLIS_PER_DAY) + cutOffDate;
return key;
}

Expand Down

0 comments on commit 254af99

Please sign in to comment.