-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed JodaTime dependency - migrated to java.time. #133
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,15 @@ | |
|
||
package in.zapr.druid.druidry.granularity; | ||
|
||
import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import org.joda.time.DateTime; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
|
||
import java.time.temporal.Temporal; | ||
|
||
@Getter | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@EqualsAndHashCode(callSuper = true) | ||
|
@@ -34,19 +35,19 @@ public class DurationGranularity extends Granularity { | |
private final String type; | ||
@JsonProperty("duration") | ||
private long durationInMilliSeconds; | ||
private DateTime origin; | ||
private Temporal origin; | ||
|
||
public DurationGranularity(long durationInMilliSeconds) { | ||
this(durationInMilliSeconds, null); | ||
} | ||
|
||
public DurationGranularity(long durationInMilliSeconds, DateTime origin) { | ||
public DurationGranularity(long durationInMilliSeconds, Temporal origin) { | ||
this.type = DURATION_GRANULARITY_TYPE; | ||
this.durationInMilliSeconds = durationInMilliSeconds; | ||
this.origin = origin; | ||
} | ||
|
||
public String getOrigin() { | ||
return origin == null ? null : origin.toDateTimeISO().toString(); | ||
return origin == null ? null : ISO_DATE_TIME.format(origin); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should use |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,29 +17,31 @@ | |
package in.zapr.druid.druidry.query.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
import org.joda.time.DateTime; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
|
||
import java.time.format.DateTimeFormatter; | ||
import java.time.temporal.TemporalAccessor; | ||
|
||
@Getter | ||
@EqualsAndHashCode | ||
public class Interval { | ||
|
||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); | ||
|
||
private final static String DRUID_INTERVAL_FORMAT = "%s/%s"; | ||
|
||
private DateTime startTime; | ||
private DateTime endTime; | ||
private TemporalAccessor startTime; | ||
private TemporalAccessor endTime; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar consideration here for |
||
|
||
public Interval(@NonNull DateTime startTime, @NonNull DateTime endTime) { | ||
public Interval(@NonNull TemporalAccessor startTime, @NonNull TemporalAccessor endTime) { | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
} | ||
|
||
@JsonValue | ||
private String getIntervalAsString() { | ||
return String.format(DRUID_INTERVAL_FORMAT, startTime.toDateTimeISO(), endTime.toDateTimeISO()); | ||
return String.format(DRUID_INTERVAL_FORMAT, FORMATTER.format(startTime), FORMATTER.format(endTime)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here also there will be contract issue and library might be giving wrong interval/s than what user intended as we are not including offset which was getting included before with Eg : Now |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep
origin
asTemporal
and user set it toYear
,Instant
, etc then wouldn'tgetOrigin
fail withUnsupportedTemporalTypeException
? Shouldn't we keeporigin
asZonedDateTime
?