當前位置: 首頁>>代碼示例>>Java>>正文


Java PeriodType.forFields方法代碼示例

本文整理匯總了Java中org.joda.time.PeriodType.forFields方法的典型用法代碼示例。如果您正苦於以下問題:Java PeriodType.forFields方法的具體用法?Java PeriodType.forFields怎麽用?Java PeriodType.forFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.PeriodType的用法示例。


在下文中一共展示了PeriodType.forFields方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: numberOfIntervalsBetweenDates

import org.joda.time.PeriodType; //導入方法依賴的package包/類
private long numberOfIntervalsBetweenDates(DateTime timestampStart, DateTime timestampEnd) {
  Period period = new Period(timestampStart, timestampEnd,
      PeriodType.forFields(new DurationFieldType[] { durationFieldType(intervalType) }));
  return period.get(durationFieldType(intervalType));
}
 
開發者ID:apache,項目名稱:beam,代碼行數:6,代碼來源:BeamSqlTimestampMinusTimestampExpression.java

示例2: DateDiscreteDomain

import org.joda.time.PeriodType; //導入方法依賴的package包/類
private DateDiscreteDomain(DurationFieldType iterationFieldType, DateTimeFieldType roundFloorFieldType) {
	this.iterationFieldType = iterationFieldType;
	this.roundFieldType = roundFloorFieldType;
	this.periodType = PeriodType.forFields(new DurationFieldType[] { iterationFieldType });
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:6,代碼來源:DateDiscreteDomain.java

示例3: inferTimeBucketSize

import org.joda.time.PeriodType; //導入方法依賴的package包/類
private String inferTimeBucketSize() {
    Period period = new Period(start, end,
            PeriodType.forFields(new DurationFieldType[]{DurationFieldType.weeks(), DurationFieldType.days(),
                    DurationFieldType.hours(), DurationFieldType.minutes(), DurationFieldType.seconds()})
    );
    // try various sizes from smallest to largest until we find one that gives us number of buckets no more than we want
    for(int i = 0; i <= 4; i++) {
        int buckets;
        String value;
        switch (i) {
            case 4: {
                buckets = period.toStandardWeeks().getWeeks();
                value = "1w";
                break;
            }
            case 3: {
                buckets = period.toStandardDays().getDays();
                value = "1d";
                break;
            }
            case 2: {
                buckets = period.toStandardHours().getHours();
                value = "1h";
                break;
            }
            case 1: {
                buckets = period.toStandardMinutes().getMinutes();
                value = "1m";
                break;
            }
            case 0: {
                buckets = period.toStandardSeconds().getSeconds();
                value = "1s";
                break;
            }
            default: {
                throw new RuntimeException("Shouldn't happen");
            }
        }
        if(buckets < MAX_RECOMMENDED_BUCKETS) {
            return value;
        }
    }
    // we should never get here but just in case
    return "1w";
}
 
開發者ID:indeedeng,項目名稱:iql,代碼行數:47,代碼來源:IQLTranslator.java


注:本文中的org.joda.time.PeriodType.forFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。