public class DateTimeUtils extends Object
| Constructor and Description |
|---|
DateTimeUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.joda.time.DateTime |
addTimeGrain(org.joda.time.DateTime dateTime,
TimeGrain timeGrain)
Adds timeGrain to a given dateTime.
|
static SortedSet<org.joda.time.Interval> |
findFullAvailabilityGaps(Set<org.joda.time.Interval> availableIntervals,
Set<org.joda.time.Interval> neededIntervals)
Finds the gaps in available vs needed interval sets.
|
static org.joda.time.DateTimeZone |
getTimeZone(Granularity granularity)
Given a granularity, produce a time zone.
|
static String |
intervalToString(org.joda.time.Interval interval,
org.joda.time.format.DateTimeFormatter formatter,
String separator)
Converts an interval to a specified string format.
|
static Set<org.joda.time.Interval> |
mergeIntervalSet(Set<org.joda.time.Interval> unmergedIntervals)
Merge all contiguous and overlapping intervals in a set together and return the set with the merged intervals.
|
static Set<org.joda.time.Interval> |
mergeIntervalToSet(Set<org.joda.time.Interval> intervals,
org.joda.time.Interval intervalToMerge)
Merge an interval into the given interval set.
|
static org.joda.time.DateTime |
quarterlyRound(org.joda.time.DateTime from)
Round the date time back to the beginning of the nearest (inclusive) month of January, April, July, October.
|
static List<org.joda.time.Interval> |
sliceIntervals(org.joda.time.Interval interval,
TimeGrain timeGrain)
Slices the intervals into smaller intervals of the timeGrain duration.
|
public static org.joda.time.DateTime addTimeGrain(org.joda.time.DateTime dateTime,
TimeGrain timeGrain)
dateTime - dateTime to which timeGrain is to be addedtimeGrain - timeGrain to be addedpublic static Set<org.joda.time.Interval> mergeIntervalSet(Set<org.joda.time.Interval> unmergedIntervals)
unmergedIntervals - A set of intervals that may abut or overlappublic static Set<org.joda.time.Interval> mergeIntervalToSet(Set<org.joda.time.Interval> intervals, org.joda.time.Interval intervalToMerge)
intervals - set of intervals to which an interval is to be added/mergedintervalToMerge - interval to be mergedpublic static SortedSet<org.joda.time.Interval> findFullAvailabilityGaps(Set<org.joda.time.Interval> availableIntervals, Set<org.joda.time.Interval> neededIntervals)
availableIntervals - availability intervalsneededIntervals - needed intervalspublic static String intervalToString(org.joda.time.Interval interval, org.joda.time.format.DateTimeFormatter formatter, String separator)
interval - interval to be formattedformatter - date time formatter for theseparator - string to separate interval start and endpublic static List<org.joda.time.Interval> sliceIntervals(org.joda.time.Interval interval, TimeGrain timeGrain)
interval - interval to be slicedtimeGrain - size of the sliceIllegalArgumentException - if the interval is not an even multiple of the time grainpublic static org.joda.time.DateTime quarterlyRound(org.joda.time.DateTime from)
from - the date being roundedpublic static org.joda.time.DateTimeZone getTimeZone(Granularity granularity)
granularity - The granularity's time zone, or if there isn't one, the default time zoneCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.