/** * Is this time interval after the specified millisecond instant. * <p> * Intervals are inclusive of the start instant and exclusive of the end. * * @param millisInstant the instant to compare to, * millisecond instant from 1970-01-01T00:00:00Z * @return true if this time interval is after the instant */ public boolean isAfter(long millisInstant) { return (getStartMillis() > millisInstant); }
/** * Is this time interval after the specified millisecond instant. * <p> * Intervals are inclusive of the start instant and exclusive of the end. * * @param millisInstant the instant to compare to, * millisecond instant from 1970-01-01T00:00:00Z * @return true if this time interval is after the instant */ public boolean isAfter(long millisInstant) { return (getStartMillis() > millisInstant); }
/** * Gets the start of this time interval, which is inclusive, as a DateTime. * * @return the start of the time interval */ public DateTime getStart() { return new DateTime(getStartMillis(), getChronology()); }
/** * Gets the start of this time interval, which is inclusive, as a DateTime. * * @return the start of the time interval */ public DateTime getStart() { return new DateTime(getStartMillis(), getChronology()); }
/** * Does this time interval contain the specified millisecond instant. * <p> * Non-zero duration intervals are inclusive of the start instant and * exclusive of the end. A zero duration interval cannot contain anything. * * @param millisInstant the instant to compare to, * millisecond instant from 1970-01-01T00:00:00Z * @return true if this time interval contains the millisecond */ public boolean contains(long millisInstant) { long thisStart = getStartMillis(); long thisEnd = getEndMillis(); return (millisInstant >= thisStart && millisInstant < thisEnd); }
/** * Converts the duration of the interval to a <code>Period</code> using the * All period type. * <p> * This method should be used to extract the field values describing the * difference between the start and end instants. * * @return a time period derived from the interval */ public Period toPeriod() { return new Period(getStartMillis(), getEndMillis(), getChronology()); }
/** * Converts the duration of the interval to a <code>Period</code> using the * specified period type. * <p> * This method should be used to extract the field values describing the * difference between the start and end instants. * * @param type the requested type of the duration, null means AllType * @return a time period derived from the interval */ public Period toPeriod(PeriodType type) { return new Period(getStartMillis(), getEndMillis(), type, getChronology()); }
/** * Converts the duration of the interval to a <code>Period</code> using the * All period type. * <p> * This method should be used to extract the field values describing the * difference between the start and end instants. * * @return a time period derived from the interval */ public Period toPeriod() { return new Period(getStartMillis(), getEndMillis(), getChronology()); }
/** * Hashcode compatible with equals method. * * @return suitable hashcode */ public int hashCode() { long start = getStartMillis(); long end = getEndMillis(); int result = 97; result = 31 * result + ((int) (start ^ (start >>> 32))); result = 31 * result + ((int) (end ^ (end >>> 32))); result = 31 * result + getChronology().hashCode(); return result; }
/** * Converts the duration of the interval to a <code>Period</code> using the * specified period type. * <p> * This method should be used to extract the field values describing the * difference between the start and end instants. * * @param type the requested type of the duration, null means AllType * @return a time period derived from the interval */ public Period toPeriod(PeriodType type) { return new Period(getStartMillis(), getEndMillis(), type, getChronology()); }
/** * Hashcode compatible with equals method. * * @return suitable hashcode */ public int hashCode() { long start = getStartMillis(); long end = getEndMillis(); int result = 97; result = 31 * result + ((int) (start ^ (start >>> 32))); result = 31 * result + ((int) (end ^ (end >>> 32))); result = 31 * result + getChronology().hashCode(); return result; }
/** * Gets the duration of this time interval in milliseconds. * <p> * The duration is equal to the end millis minus the start millis. * * @return the duration of the time interval in milliseconds * @throws ArithmeticException if the duration exceeds the capacity of a long */ public long toDurationMillis() { return FieldUtils.safeSubtract(getEndMillis(), getStartMillis()); }
/** * Gets the duration of this time interval in milliseconds. * <p> * The duration is equal to the end millis minus the start millis. * * @return the duration of the time interval in milliseconds * @throws ArithmeticException if the duration exceeds the capacity of a long */ public long toDurationMillis() { return FieldUtils.safeSubtract(getEndMillis(), getStartMillis()); }
/** * Output a string in ISO8601 interval format. * <p> * From version 2.1, the string includes the time zone offset. * * @return re-parsable string (in the default zone) */ public String toString() { DateTimeFormatter printer = ISODateTimeFormat.dateTime(); printer = printer.withChronology(getChronology()); StringBuffer buf = new StringBuffer(48); printer.printTo(buf, getStartMillis()); buf.append('/'); printer.printTo(buf, getEndMillis()); return buf.toString(); }
/** * Get this time interval as a <code>MutableInterval</code>. * <p> * This will always return a new <code>MutableInterval</code> with the same interval. * * @return the time interval as a MutableInterval object */ public MutableInterval toMutableInterval() { return new MutableInterval(getStartMillis(), getEndMillis(), getChronology()); }
/** * Get this interval as an immutable <code>Interval</code> object. * * @return the interval as an Interval object */ public Interval toInterval() { return new Interval(getStartMillis(), getEndMillis(), getChronology()); }
/** * Get this interval as an immutable <code>Interval</code> object. * * @return the interval as an Interval object */ public Interval toInterval() { return new Interval(getStartMillis(), getEndMillis(), getChronology()); }
/** * Get this time interval as a <code>MutableInterval</code>. * <p> * This will always return a new <code>MutableInterval</code> with the same interval. * * @return the time interval as a MutableInterval object */ public MutableInterval toMutableInterval() { return new MutableInterval(getStartMillis(), getEndMillis(), getChronology()); }
/** * Is this interval equal to the specified interval ignoring the chronology. * <p> * This compares the underlying instants, ignoring the chronology. * * @param other a readable interval to check against * @return true if the intervals are equal comparing the start and end millis * @since 2.3 */ public boolean isEqual(ReadableInterval other) { return getStartMillis() == other.getStartMillis() && getEndMillis() == other.getEndMillis(); }
/** * Is this interval equal to the specified interval ignoring the chronology. * <p> * This compares the underlying instants, ignoring the chronology. * * @param other a readable interval to check against * @return true if the intervals are equal comparing the start and end millis * @since 2.3 */ public boolean isEqual(ReadableInterval other) { return getStartMillis() == other.getStartMillis() && getEndMillis() == other.getEndMillis(); }