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

x33g5p2x  于2022-01-17 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(116)

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

DateTime.property介绍

[英]Gets the property object for the specified type, which contains many useful methods.
[中]获取指定类型的属性对象,该类型包含许多有用的方法。

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Return the maximum value of a field, closest to the reference time
 */
public static int maximumValue(DateTimeFieldType type, ReadableDateTime reference){
 return reference.toDateTime().property(type).getMaximumValue();
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * Return the minimum value of a field, closest to the reference time
 */
public static int minimumValue(DateTimeFieldType type, ReadableDateTime reference){
 return reference.toDateTime().property(type).getMinimumValue();
}
/**

代码示例来源:origin: facebook/jcommon

/**
 * Gets the start instant given the event instant, interval length
 * and the time zone for this interval type.
 *
 * @param instant the event time instant.
 * @param length the interval length
 *
 * @return the start instant of the interval of given length that contains
 * the supplied time instant in the supplied time zone
 */
public DateTime getTimeIntervalStart(DateTime instant, long length) {
 validateValue(instant.getZone(), length);
 // Reset all the fields
 DateTime periodStart = instant.property(truncateFieldType)
  .roundFloorCopy();
 // figure out the which time interval does the instant lie in
 Period period = new Period(periodStart, instant, periodType);
 DurationField durationField = fieldType.getField(instant.getChronology()).getDurationField();
 int diff = period.get(durationField.getType());
 long startDelta = (diff / length) * length;
 return periodStart.withFieldAdded(durationField.getType(), FieldUtils.safeToInt(startDelta));
}

代码示例来源:origin: stackoverflow.com

int year = 2012;
 DateTime dt = new DateTime(year, 01, 01, 00, 00, 00, 00);
 for (int i = 0; i < 12; i++) {
   System.out.println(dt.toString() + " " + dt.property(DateTimeFieldType.dayOfWeek()).getAsText());
   dt = dt.plusMonths(1);
 }

代码示例来源:origin: org.opencds.cqf/cql-engine

public static int[] getValues(org.joda.time.DateTime dt, int numElements) {
  List<Integer> values = new ArrayList<Integer>();
  for (int i = 0; i < numElements; ++i) {
    values.add(dt.property(DateTime.getField(i)).get());
  }
  return values.stream().mapToInt(i -> i).toArray();
}

代码示例来源:origin: com.guokr/stan-cn-com

/**
 * Return the maximum value of a field, closest to the reference time
 */
public static int maximumValue(DateTimeFieldType type, ReadableDateTime reference){
 return reference.toDateTime().property(type).getMaximumValue();
}

代码示例来源:origin: edu.stanford.nlp/stanford-corenlp

/**
 * Return the minimum value of a field, closest to the reference time
 */
public static int minimumValue(DateTimeFieldType type, ReadableDateTime reference){
 return reference.toDateTime().property(type).getMinimumValue();
}
/**

代码示例来源:origin: edu.stanford.nlp/stanford-corenlp

/**
 * Return the maximum value of a field, closest to the reference time
 */
public static int maximumValue(DateTimeFieldType type, ReadableDateTime reference){
 return reference.toDateTime().property(type).getMaximumValue();
}

代码示例来源:origin: com.guokr/stan-cn-com

/**
 * Return the minimum value of a field, closest to the reference time
 */
public static int minimumValue(DateTimeFieldType type, ReadableDateTime reference){
 return reference.toDateTime().property(type).getMinimumValue();
}
/**

代码示例来源:origin: Jasig/uPortal

/**
   * Determine the ending DateTime (exclusive) of an interval based on an instant in time
   *
   * @param instant The start of an instant
   * @return
   */
  public DateTime determineEnd(DateTime instant) {
    if (this.dateTimeFieldType != null) {
      final DateTime start = instant.property(this.dateTimeFieldType).roundFloorCopy();
      return start.property(this.dateTimeFieldType).addToCopy(1);
    }

    if (this == AggregationInterval.FIVE_MINUTE) {
      final DateTime start =
          instant.hourOfDay()
              .roundFloorCopy()
              .plusMinutes((instant.getMinuteOfHour() / 5) * 5);
      return start.plusMinutes(5);
    }

    throw new IllegalArgumentException(
        "Cannot compute interval end time for "
            + this
            + " please use "
            + AggregationIntervalHelper.class);
  }
}

代码示例来源:origin: Jasig/uPortal

/**
 * Determine the starting DateTime (inclusive) of an interval based on an instant in time
 *
 * @param instant The instant in time to get the interval starting value for
 * @return The start of this interval in relation to the provided instant
 */
public DateTime determineStart(DateTime instant) {
  if (this.dateTimeFieldType != null) {
    return instant.property(this.dateTimeFieldType).roundFloorCopy();
  }
  if (this == AggregationInterval.FIVE_MINUTE) {
    return instant.hourOfDay()
        .roundFloorCopy()
        .plusMinutes((instant.getMinuteOfHour() / 5) * 5);
  }
  throw new IllegalArgumentException(
      "Cannot compute interval start time for "
          + this
          + " please use "
          + AggregationIntervalHelper.class);
}

代码示例来源:origin: perfectsense/dari

protected DateTime every(DateTime currentTime, DateTimeFieldType unit, int offset, int interval) {
  DateTime d = currentTime.property(unit).roundFloorCopy();
  d = d.withFieldAdded(unit.getDurationType(), offset);
  return d.withField(unit, (d.get(unit) / interval) * interval);
}

代码示例来源:origin: com.addthis/basis

public IterableInterval(Interval interval, DTimeUnit per) {
  if (per == DTimeUnit.ALL_TIME) {
    this.increment = period(1, PeriodType.millis());
    this.end = interval.getStart();
    this.currentInstant = end.minus(increment);
  } else {
    this.increment = period(1, per.toPeriodType());
    this.end = interval.getEnd().property(per.toDateTimeFieldType()).roundFloorCopy();
    this.currentInstant = interval.getStart().minus(increment);
  }
}

相关文章

DateTime类方法