当前位置: 首页>>代码示例>>Java>>正文


Java DurationFieldType.years方法代码示例

本文整理汇总了Java中org.joda.time.DurationFieldType.years方法的典型用法代码示例。如果您正苦于以下问题:Java DurationFieldType.years方法的具体用法?Java DurationFieldType.years怎么用?Java DurationFieldType.years使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.DurationFieldType的用法示例。


在下文中一共展示了DurationFieldType.years方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDurationFieldType

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
private static DurationFieldType getDurationFieldType(OrgInterval.Unit unit) {
    switch (unit) {
        case HOUR:
            return DurationFieldType.hours();
        case DAY:
            return DurationFieldType.days();
        case WEEK:
            return DurationFieldType.weeks();
        case MONTH:
            return DurationFieldType.months();
        case YEAR:
            return DurationFieldType.years();
        default:
            throw new IllegalArgumentException("Unknown unit " + unit);
    }
}
 
开发者ID:orgzly,项目名称:org-java,代码行数:17,代码来源:OrgDateTimeUtils.java

示例2: testAdd

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, GJChronology.getInstance(DateTimeZone.UTC));
    DateTime dtEnd = new DateTime(end, GJChronology.getInstance(DateTimeZone.UTC));
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(GJChronology.getInstance(DateTimeZone.UTC));
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);
    
    if (type == DurationFieldType.years() ||
        type == DurationFieldType.months() ||
        type == DurationFieldType.days()) {
        YearMonthDay ymdStart = new YearMonthDay(start, GJChronology.getInstance(DateTimeZone.UTC));
        YearMonthDay ymdEnd = new YearMonthDay(end, GJChronology.getInstance(DateTimeZone.UTC));
        assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
        assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:TestGJChronology.java

示例3: testAdd

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, ISOChronology.getInstanceUTC());
    DateTime dtEnd = new DateTime(end, ISOChronology.getInstanceUTC());
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(ISOChronology.getInstanceUTC());
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);
    
    if (type == DurationFieldType.years() ||
        type == DurationFieldType.months() ||
        type == DurationFieldType.days()) {
        YearMonthDay ymdStart = new YearMonthDay(start, ISOChronology.getInstanceUTC());
        YearMonthDay ymdEnd = new YearMonthDay(end, ISOChronology.getInstanceUTC());
        assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
        assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:TestISOChronology.java

示例4: FixedYearLengthChronology

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
/**
 * @param daysInYear The number of days in each year
 */
protected FixedYearLengthChronology(int daysInYear) {
    this.daysInYear = daysInYear;

    this.yearDuration = new PreciseDurationField(DurationFieldType.years(),
            daysInYear * dayDuration.getUnitMillis());
    this.centuryDuration = new PreciseDurationField(DurationFieldType.centuries(),
            100 * yearDuration.getUnitMillis());

    this.dayOfYear = new OneBasedPreciseDateTimeField(DateTimeFieldType.dayOfYear(),
            dayDuration, this.yearDuration);
    this.yearOfCentury =  new PreciseDateTimeField(DateTimeFieldType.yearOfCentury(),
            this.yearDuration, this.centuryDuration);
    this.year = new YearField(this.yearDuration);
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:18,代码来源:FixedYearLengthChronology.java

示例5: FixedYearLengthChronology

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
/**
 * @param daysInYear
 *            The number of days in each year
 */
protected FixedYearLengthChronology(int daysInYear) {
    this.daysInYear = daysInYear;

    this.yearDuration = new PreciseDurationField(DurationFieldType.years(), daysInYear
            * dayDuration.getUnitMillis());
    this.centuryDuration = new PreciseDurationField(DurationFieldType.centuries(),
            100 * yearDuration.getUnitMillis());

    this.dayOfYear = new OneBasedPreciseDateTimeField(DateTimeFieldType.dayOfYear(),
            dayDuration, this.yearDuration);
    this.yearOfCentury = new PreciseDateTimeField(DateTimeFieldType.yearOfCentury(),
            this.yearDuration, this.centuryDuration);
    this.year = new YearField(this.yearDuration);
}
 
开发者ID:Reading-eScience-Centre,项目名称:edal-java,代码行数:19,代码来源:FixedYearLengthChronology.java

示例6: getRangeDurationType

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
@Override
public DurationFieldType getRangeDurationType() {
    return DurationFieldType.years();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:Joda.java

示例7: age

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
public static int age(final DateTime birthday) {
  DateTime _now = DateTime.now();
  Years _yearsBetween = Years.yearsBetween(birthday, _now);
  DurationFieldType _years = DurationFieldType.years();
  return _yearsBetween.get(_years);
}
 
开发者ID:East196,项目名称:maker,代码行数:7,代码来源:Randoms.java

示例8: getRangeDurationType

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
@Override
public DurationFieldType getRangeDurationType()
{
    return DurationFieldType.years();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:6,代码来源:QuarterOfYearDateTimeField.java

示例9: DateTimeConvertor

import org.joda.time.DurationFieldType; //导入方法依赖的package包/类
public DateTimeConvertor(DateTimeFormatSpec inputFormat, DateTimeFormatSpec outputFormat,
    DateTimeGranularitySpec outputGranularity) {

  inputTimeSize = inputFormat.getColumnSize();
  inputTimeUnit = inputFormat.getColumnUnit();
  TimeFormat inputTimeFormat = inputFormat.getTimeFormat();
  if (inputTimeFormat.equals(TimeFormat.SIMPLE_DATE_FORMAT)) {
    inputDateTimeFormatter = inputFormat.getDateTimeFormatter();
  }

  outputTimeSize = outputFormat.getColumnSize();
  outputTimeUnit = outputFormat.getColumnDateTimeTransformUnit();
  TimeFormat outputTimeFormat = outputFormat.getTimeFormat();
  if (outputTimeFormat.equals(TimeFormat.EPOCH)) {
    DurationFieldType durationFieldType;
    switch (outputTimeUnit) {

    case YEARS:
      durationFieldType = DurationFieldType.years();
      break;
    case MONTHS:
      durationFieldType = DurationFieldType.months();
      break;
    case WEEKS:
      durationFieldType = DurationFieldType.weeks();
      break;
    case DAYS:
      durationFieldType = DurationFieldType.days();
      break;
    case HOURS:
      durationFieldType = DurationFieldType.hours();
      break;
    case MINUTES:
      durationFieldType = DurationFieldType.minutes();
      break;
    case SECONDS:
      durationFieldType = DurationFieldType.seconds();
      break;
    case MILLISECONDS:
      durationFieldType = DurationFieldType.millis();
      break;
    default:
      throw new IllegalArgumentException("Illegal argument for time unit: " + outputTimeUnit);
    }
    outputDurationField = durationFieldType.getField(EPOCH_START_CHRONOLOGY);

  } else {
    outputDateTimeFormatter = outputFormat.getDateTimeFormatter();
  }

  outputGranularityMillis = outputGranularity.granularityToMillis();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:53,代码来源:DateTimeConvertor.java


注:本文中的org.joda.time.DurationFieldType.years方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。