当前位置: 首页>>代码示例>>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;未经允许,请勿转载。