public class DateTimeService extends Object
| Modifier and Type | Field and Description |
|---|---|
protected MetricsConfiguration |
configuration |
| Constructor and Description |
|---|
DateTimeService() |
| Modifier and Type | Method and Description |
|---|---|
org.joda.time.DateTime |
current24HourTimeSlice()
The 24 hour time slices are fix - 00:00 to 24:00.
|
org.joda.time.DateTime |
current6HourTimeSlice()
The six hour time slices for a day are fixed - 00:00 to 06:00, 06:00 to 12:00, 12:00 to 18:00, 18:00 to 24:00.
|
org.joda.time.DateTime |
currentHour() |
org.joda.time.DateTime |
get24HourTimeSlice(org.joda.time.DateTime time)
This method determines the 24 hour time slice for the specified time and returns the start of that time slice.
|
org.joda.time.DateTime |
get24HourTimeSlice(long timestamp) |
org.joda.time.DateTime |
get24HourTimeSliceEnd(org.joda.time.DateTime time) |
org.joda.time.DateTime |
get6HourTimeSlice(org.joda.time.DateTime time)
This method determines the six hour time slice for the specified time and returns the start of that time slice.
|
org.joda.time.DateTime |
get6HourTimeSlice(long timestamp) |
org.joda.time.DateTime |
get6HourTimeSliceEnd(org.joda.time.DateTime time) |
org.joda.time.DateTime |
getTimeSlice(org.joda.time.DateTime dt,
org.joda.time.Duration duration) |
org.joda.time.DateTime |
getTimeSlice(long timestamp,
org.joda.time.Duration duration) |
org.joda.time.DateTime |
hour0() |
boolean |
is24HourTimeSliceFinished(org.joda.time.DateTime time)
Determines if the current 24 hour time slice for the specified time has completed.
|
boolean |
is24HourTimeSliceFinished(long timestamp) |
boolean |
is6HourTimeSliceFinished(org.joda.time.DateTime time)
Determines if the current six hour time slice for the specified time has completed.
|
boolean |
is6HourTimeSliceFinished(long timestamp) |
boolean |
isIn1HourDataRange(org.joda.time.DateTime dateTime) |
boolean |
isIn24HourDataRange(org.joda.time.DateTime dateTime) |
boolean |
isIn6HourDataRange(org.joda.time.DateTime dateTime) |
boolean |
isInRawDataRange(org.joda.time.DateTime dateTime) |
org.joda.time.DateTime |
now()
This method is preferred over DateTime.now() and System.currentTimeMillis() because it provides a hook for tests.
|
long |
nowInMillis() |
void |
setConfiguration(MetricsConfiguration configuration) |
protected MetricsConfiguration configuration
public void setConfiguration(MetricsConfiguration configuration)
public org.joda.time.DateTime now()
public long nowInMillis()
public org.joda.time.DateTime getTimeSlice(long timestamp,
org.joda.time.Duration duration)
public org.joda.time.DateTime getTimeSlice(org.joda.time.DateTime dt,
org.joda.time.Duration duration)
public boolean isInRawDataRange(org.joda.time.DateTime dateTime)
public boolean isIn1HourDataRange(org.joda.time.DateTime dateTime)
public boolean isIn6HourDataRange(org.joda.time.DateTime dateTime)
public boolean isIn24HourDataRange(org.joda.time.DateTime dateTime)
public org.joda.time.DateTime currentHour()
public org.joda.time.DateTime current6HourTimeSlice()
currentHour() and returns the start of the time
slice.public org.joda.time.DateTime current24HourTimeSlice()
currentHour() and returns the start of the time slice.public org.joda.time.DateTime get24HourTimeSlice(org.joda.time.DateTime time)
time - The DateTime to be rounded downcurrent24HourTimeSlice()public org.joda.time.DateTime get24HourTimeSliceEnd(org.joda.time.DateTime time)
public org.joda.time.DateTime get24HourTimeSlice(long timestamp)
public org.joda.time.DateTime get6HourTimeSlice(org.joda.time.DateTime time)
time - The DateTime to be rounded downcurrent6HourTimeSlice()public org.joda.time.DateTime get6HourTimeSlice(long timestamp)
public org.joda.time.DateTime get6HourTimeSliceEnd(org.joda.time.DateTime time)
public boolean is6HourTimeSliceFinished(org.joda.time.DateTime time)
Suppose that the current time is 14:23 and that the specified time is 13:15:00 which falls into the 12:00 - 18:00 time slice. In this case the time slice has not yet finished.
Now suppose that the current time is 12:24 and the specified time is 11:34 which falls into the 06:00 - 12:00 time slice. In this case the time slice has finished.
time - The DateTime to evaluatepublic boolean is6HourTimeSliceFinished(long timestamp)
public boolean is24HourTimeSliceFinished(org.joda.time.DateTime time)
Suppose that the current time 22:12 Monday and that the specified time is 21:48. The current time slice, i.e., Monday, has not yet finished.
Now suppose that the current time is 01:13 Tuesday and that the specified time is 23:19 Monday. The time slice for the specified time has finished.
time - The DateTime to evaluatepublic boolean is24HourTimeSliceFinished(long timestamp)
public org.joda.time.DateTime hour0()
Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.