Java Code Examples for org.joda.time.DateTimeUtils#getDurationMillis()

The following examples show how to use org.joda.time.DateTimeUtils#getDurationMillis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Time_22_BasePeriod_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a period from the given start point and duration.
 *
 * @param startInstant  the interval start, null means now
 * @param duration  the duration of the interval, null means zero-length
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long startMillis = DateTimeUtils.getInstantMillis(startInstant);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = FieldUtils.safeAdd(startMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(startInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}
 
Example 2
Source File: Time_22_BasePeriod_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a period from the given duration and end point.
 *
 * @param duration  the duration of the interval, null means zero-length
 * @param endInstant  the interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = DateTimeUtils.getInstantMillis(endInstant);
    long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(endInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}
 
Example 3
Source File: Time_22_BasePeriod_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a period from the given start point and duration.
 *
 * @param startInstant  the interval start, null means now
 * @param duration  the duration of the interval, null means zero-length
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long startMillis = DateTimeUtils.getInstantMillis(startInstant);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = FieldUtils.safeAdd(startMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(startInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}
 
Example 4
Source File: Time_22_BasePeriod_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a period from the given duration and end point.
 *
 * @param duration  the duration of the interval, null means zero-length
 * @param endInstant  the interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = DateTimeUtils.getInstantMillis(endInstant);
    long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(endInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}
 
Example 5
Source File: BaseInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs an interval from a start instant and a duration.
 * 
 * @param start  start of this interval, null means now
 * @param duration  the duration of this interval, null means zero length
 * @throws IllegalArgumentException if the end is before the start
 * @throws ArithmeticException if the end instant exceeds the capacity of a long
 */
protected BaseInterval(ReadableInstant start, ReadableDuration duration) {
    super();
    iChronology = DateTimeUtils.getInstantChronology(start);
    iStartMillis = DateTimeUtils.getInstantMillis(start);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    iEndMillis = FieldUtils.safeAdd(iStartMillis, durationMillis);
    checkInterval(iStartMillis, iEndMillis);
}
 
Example 6
Source File: BaseInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: BasePeriod.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a period from the given start point and duration.
 *
 * @param startInstant  the interval start, null means now
 * @param duration  the duration of the interval, null means zero-length
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long startMillis = DateTimeUtils.getInstantMillis(startInstant);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = FieldUtils.safeAdd(startMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(startInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}
 
Example 8
Source File: BasePeriod.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a period from the given duration and end point.
 *
 * @param duration  the duration of the interval, null means zero-length
 * @param endInstant  the interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = DateTimeUtils.getInstantMillis(endInstant);
    long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(endInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}
 
Example 9
Source File: BaseInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs an interval from a start instant and a duration.
 * 
 * @param start  start of this interval, null means now
 * @param duration  the duration of this interval, null means zero length
 * @throws IllegalArgumentException if the end is before the start
 * @throws ArithmeticException if the end instant exceeds the capacity of a long
 */
protected BaseInterval(ReadableInstant start, ReadableDuration duration) {
    super();
    iChronology = DateTimeUtils.getInstantChronology(start);
    iStartMillis = DateTimeUtils.getInstantMillis(start);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    iEndMillis = FieldUtils.safeAdd(iStartMillis, durationMillis);
    checkInterval(iStartMillis, iEndMillis);
}
 
Example 10
Source File: BaseInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: BasePeriod.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a period from the given start point and duration.
 *
 * @param startInstant  the interval start, null means now
 * @param duration  the duration of the interval, null means zero-length
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long startMillis = DateTimeUtils.getInstantMillis(startInstant);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = FieldUtils.safeAdd(startMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(startInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}
 
Example 12
Source File: BasePeriod.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a period from the given duration and end point.
 *
 * @param duration  the duration of the interval, null means zero-length
 * @param endInstant  the interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 */
protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    long durationMillis = DateTimeUtils.getDurationMillis(duration);
    long endMillis = DateTimeUtils.getInstantMillis(endInstant);
    long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis);
    Chronology chrono = DateTimeUtils.getInstantChronology(endInstant);
    iType = type;
    iValues = chrono.get(this, startMillis, endMillis);
}