org.joda.time.Partial.indexOf()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(16.0k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.joda.time.Partial.indexOf()方法的一些代码示例,展示了Partial.indexOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Partial.indexOf()方法的具体详情如下:
包路径:org.joda.time.Partial
类名称:Partial
方法名:indexOf

Partial.indexOf介绍

暂无

代码示例

代码示例来源:origin: joda-time/joda-time

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: joda-time/joda-time

/**
 * Gets a copy of this Partial with the specified period added.
 * <p>
 * If the addition is zero, then <code>this</code> is returned.
 * Fields in the period that aren't present in the partial are ignored.
 * <p>
 * This method is typically used to add multiple copies of complex
 * period instances. Adding one field is best achieved using the method
 * {@link #withFieldAdded(DurationFieldType, int)}.
 * 
 * @param period  the period to add to this one, null means zero
 * @param scalar  the amount of times to add, such as -1 to subtract once
 * @return a copy of this instance with the period added
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withPeriodAdded(ReadablePeriod period, int scalar) {
  if (period == null || scalar == 0) {
    return this;
  }
  int[] newValues = getValues();
  for (int i = 0; i < period.size(); i++) {
    DurationFieldType fieldType = period.getFieldType(i);
    int index = indexOf(fieldType);
    if (index >= 0) {
      newValues = getField(index).add(this, index, newValues,
          FieldUtils.safeMultiply(period.getValue(i), scalar));
    }
  }
  return new Partial(this, newValues);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Gets a copy of this Partial with the specified period added.
 * <p>
 * If the addition is zero, then <code>this</code> is returned.
 * Fields in the period that aren't present in the partial are ignored.
 * <p>
 * This method is typically used to add multiple copies of complex
 * period instances. Adding one field is best achieved using the method
 * {@link #withFieldAdded(DurationFieldType, int)}.
 * 
 * @param period  the period to add to this one, null means zero
 * @param scalar  the amount of times to add, such as -1 to subtract once
 * @return a copy of this instance with the period added
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withPeriodAdded(ReadablePeriod period, int scalar) {
  if (period == null || scalar == 0) {
    return this;
  }
  int[] newValues = getValues();
  for (int i = 0; i < period.size(); i++) {
    DurationFieldType fieldType = period.getFieldType(i);
    int index = indexOf(fieldType);
    if (index >= 0) {
      newValues = getField(index).add(this, index, newValues,
          FieldUtils.safeMultiply(period.getValue(i), scalar));
    }
  }
  return new Partial(this, newValues);
}

代码示例来源:origin: joda-time/joda-time

throw new IllegalArgumentException("The field type must not be null");
int index = indexOf(fieldType);
if (index == -1) {
  DateTimeFieldType[] newTypes = new DateTimeFieldType[iTypes.length + 1];

代码示例来源:origin: JodaOrg/joda-time

throw new IllegalArgumentException("The field type must not be null");
int index = indexOf(fieldType);
if (index == -1) {
  DateTimeFieldType[] newTypes = new DateTimeFieldType[iTypes.length + 1];

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Gets a copy of this Partial with the specified period added.
 * <p>
 * If the addition is zero, then <code>this</code> is returned.
 * Fields in the period that aren't present in the partial are ignored.
 * <p>
 * This method is typically used to add multiple copies of complex
 * period instances. Adding one field is best achieved using the method
 * {@link #withFieldAdded(DurationFieldType, int)}.
 * 
 * @param period  the period to add to this one, null means zero
 * @param scalar  the amount of times to add, such as -1 to subtract once
 * @return a copy of this instance with the period added
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withPeriodAdded(ReadablePeriod period, int scalar) {
  if (period == null || scalar == 0) {
    return this;
  }
  int[] newValues = getValues();
  for (int i = 0; i < period.size(); i++) {
    DurationFieldType fieldType = period.getFieldType(i);
    int index = indexOf(fieldType);
    if (index >= 0) {
      newValues = getField(index).add(this, index, newValues,
          FieldUtils.safeMultiply(period.getValue(i), scalar));
    }
  }
  return new Partial(this, newValues);
}

代码示例来源:origin: camunda/camunda-bpm-platform

throw new IllegalArgumentException("The field type must not be null");
int index = indexOf(fieldType);
if (index == -1) {
  DateTimeFieldType[] newTypes = new DateTimeFieldType[iTypes.length + 1];

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: org.joda/com.springsource.org.joda.time

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: redfish64/TinyTravelTracker

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: Nextdoor/bender

/**
 * Gets a copy of this date with the specified field removed.
 * <p>
 * If this partial did not previously support the field, no error occurs.
 *
 * @param fieldType  the field type to remove, may be null
 * @return a copy of this instance with the field removed
 */
public Partial without(DateTimeFieldType fieldType) {
  int index = indexOf(fieldType);
  if (index != -1) {
    DateTimeFieldType[] newTypes = new DateTimeFieldType[size() - 1];
    int[] newValues = new int[size() - 1];
    System.arraycopy(iTypes, 0, newTypes, 0, index);
    System.arraycopy(iTypes, index + 1, newTypes, index, newTypes.length - index);
    System.arraycopy(iValues, 0, newValues, 0, index);
    System.arraycopy(iValues, index + 1, newValues, index, newValues.length - index);
    Partial newPartial = new Partial(iChronology, newTypes, newValues);
    iChronology.validate(newPartial, newValues);
    return newPartial;
  }
  return this;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

/**
 * Gets a copy of this Partial with the specified period added.
 * <p>
 * If the addition is zero, then <code>this</code> is returned.
 * Fields in the period that aren't present in the partial are ignored.
 * <p>
 * This method is typically used to add multiple copies of complex
 * period instances. Adding one field is best achieved using the method
 * {@link #withFieldAdded(DurationFieldType, int)}.
 * 
 * @param period  the period to add to this one, null means zero
 * @param scalar  the amount of times to add, such as -1 to subtract once
 * @return a copy of this instance with the period added
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withPeriodAdded(ReadablePeriod period, int scalar) {
  if (period == null || scalar == 0) {
    return this;
  }
  int[] newValues = getValues();
  for (int i = 0; i < period.size(); i++) {
    DurationFieldType fieldType = period.getFieldType(i);
    int index = indexOf(fieldType);
    if (index >= 0) {
      newValues = getField(index).add(this, index, newValues,
          FieldUtils.safeMultiply(period.getValue(i), scalar));
    }
  }
  return new Partial(this, newValues);
}

代码示例来源:origin: org.joda/com.springsource.org.joda.time

/**
 * Gets a copy of this Partial with the specified period added.
 * <p>
 * If the addition is zero, then <code>this</code> is returned.
 * Fields in the period that aren't present in the partial are ignored.
 * <p>
 * This method is typically used to add multiple copies of complex
 * period instances. Adding one field is best achieved using the method
 * {@link #withFieldAdded(DurationFieldType, int)}.
 * 
 * @param period  the period to add to this one, null means zero
 * @param scalar  the amount of times to add, such as -1 to subtract once
 * @return a copy of this instance with the period added
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withPeriodAdded(ReadablePeriod period, int scalar) {
  if (period == null || scalar == 0) {
    return this;
  }
  int[] newValues = getValues();
  for (int i = 0; i < period.size(); i++) {
    DurationFieldType fieldType = period.getFieldType(i);
    int index = indexOf(fieldType);
    if (index >= 0) {
      newValues = getField(index).add(this, index, newValues,
          FieldUtils.safeMultiply(period.getValue(i), scalar));
    }
  }
  return new Partial(this, newValues);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Gets a copy of this Partial with the specified period added.
 * <p>
 * If the addition is zero, then <code>this</code> is returned.
 * Fields in the period that aren't present in the partial are ignored.
 * <p>
 * This method is typically used to add multiple copies of complex
 * period instances. Adding one field is best achieved using the method
 * {@link #withFieldAdded(DurationFieldType, int)}.
 * 
 * @param period  the period to add to this one, null means zero
 * @param scalar  the amount of times to add, such as -1 to subtract once
 * @return a copy of this instance with the period added
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withPeriodAdded(ReadablePeriod period, int scalar) {
  if (period == null || scalar == 0) {
    return this;
  }
  int[] newValues = getValues();
  for (int i = 0; i < period.size(); i++) {
    DurationFieldType fieldType = period.getFieldType(i);
    int index = indexOf(fieldType);
    if (index >= 0) {
      newValues = getField(index).add(this, index, newValues,
          FieldUtils.safeMultiply(period.getValue(i), scalar));
    }
  }
  return new Partial(this, newValues);
}

相关文章