/** * Is this instant equal to the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is equal to the instant passed in */ public boolean isEqual(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isEqual(instantMillis); }
/** * Creates a new interval with the specified start instant. * * @param start the start instant for the new interval, null means now * @return an interval with the end from this interval and the specified start * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withStart(ReadableInstant start) { long startMillis = DateTimeUtils.getInstantMillis(start); return withStartMillis(startMillis); }
/** * Is this instant strictly before the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is strictly before the instant passed in */ public boolean isBefore(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isBefore(instantMillis); }
/** * Sets the millisecond instant of this instant from another. * <p> * This method does not change the chronology of this instant, just the * millisecond instant. * * @param instant the instant to use, null means now */ public void setMillis(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); setMillis(instantMillis); // set via this class not super }
/** * Is this instant strictly after the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is strictly after the instant passed in */ public boolean isAfter(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isAfter(instantMillis); }
/** * Creates a new interval with the specified end instant. * * @param end the end instant for the new interval, null means now * @return an interval with the start from this interval and the specified end * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withEnd(ReadableInstant end) { long endMillis = DateTimeUtils.getInstantMillis(end); return withEndMillis(endMillis); }
/** * Is this instant strictly after the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is strictly after the instant passed in */ public boolean isAfter(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isAfter(instantMillis); }
/** * Sets the millisecond instant of this instant from another. * <p> * This method does not change the chronology of this instant, just the * millisecond instant. * * @param instant the instant to use, null means now */ public void setMillis(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); setMillis(instantMillis); // set via this class not super }
/** * Is this instant equal to the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is equal to the instant passed in */ public boolean isEqual(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isEqual(instantMillis); }
/** * Creates a new interval with the specified start instant. * * @param start the start instant for the new interval, null means now * @return an interval with the end from this interval and the specified start * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withStart(ReadableInstant start) { long startMillis = DateTimeUtils.getInstantMillis(start); return withStartMillis(startMillis); }
/** * Is this instant strictly before the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is strictly before the instant passed in */ public boolean isBefore(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isBefore(instantMillis); }
/** * Creates a new interval with the specified end instant. * * @param end the end instant for the new interval, null means now * @return an interval with the start from this interval and the specified end * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withEnd(ReadableInstant end) { long endMillis = DateTimeUtils.getInstantMillis(end); return withEndMillis(endMillis); }
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param appendable the destination to format to, not null * @param instant instant to format, null means now * @since 2.0 */ public void printTo(Appendable appendable, ReadableInstant instant) throws IOException { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(appendable, millis, chrono); }
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param appendable the destination to format to, not null * @param instant instant to format, null means now * @since 2.0 */ public void printTo(Appendable appendable, ReadableInstant instant) throws IOException { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(appendable, millis, chrono); }
/** * Sets the start of this time interval as an Instant. * * @param start the start of the time interval, null means now * @throws IllegalArgumentException if the end is before the start */ public void setStart(ReadableInstant start) { long startMillis = DateTimeUtils.getInstantMillis(start); super.setInterval(startMillis, getEndMillis(), getChronology()); }
/** * Sets the end of this time interval as an Instant. * * @param end the end of the time interval, null means now * @throws IllegalArgumentException if the end is before the start */ public void setEnd(ReadableInstant end) { long endMillis = DateTimeUtils.getInstantMillis(end); super.setInterval(getStartMillis(), endMillis, getChronology()); }
/** * Sets the end of this time interval as an Instant. * * @param end the end of the time interval, null means now * @throws IllegalArgumentException if the end is before the start */ public void setEnd(ReadableInstant end) { long endMillis = DateTimeUtils.getInstantMillis(end); super.setInterval(getStartMillis(), endMillis, getChronology()); }
/** * Sets the start of this time interval as an Instant. * * @param start the start of the time interval, null means now * @throws IllegalArgumentException if the end is before the start */ public void setStart(ReadableInstant start) { long startMillis = DateTimeUtils.getInstantMillis(start); super.setInterval(startMillis, getEndMillis(), getChronology()); }
/** * Constructs an interval from a millisecond duration and an end instant. * * @param duration the duration of this interval, null means zero length * @param end end of this interval, null means now * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ protected BaseInterval(ReadableDuration duration, ReadableInstant end) { super(); iChronology = DateTimeUtils.getInstantChronology(end); iEndMillis = DateTimeUtils.getInstantMillis(end); long durationMillis = DateTimeUtils.getDurationMillis(duration); iStartMillis = FieldUtils.safeAdd(iEndMillis, -durationMillis); checkInterval(iStartMillis, iEndMillis); }
/** * Set the time from another instant. * The date part of this object will be unaffected. * * @param instant an instant to copy the time from, date part ignored * @throws IllegalArgumentException if the object is invalid */ public void setTime(final ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); Chronology instantChrono = DateTimeUtils.getInstantChronology(instant); DateTimeZone zone = instantChrono.getZone(); if (zone != null) { instantMillis = zone.getMillisKeepLocal(DateTimeZone.UTC, instantMillis); } setTime(instantMillis); }