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


Java Days.days方法代码示例

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


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

示例1: create

import org.joda.time.Days; //导入方法依赖的package包/类
@Override
public Object create(Object request, SpecimenContext context) {

    if (!(request instanceof SpecimenType)) {
        return new NoSpecimen();
    }

    SpecimenType type = (SpecimenType) request;
    if (!BaseSingleFieldPeriod.class.isAssignableFrom(type.getRawType())) {
        return new NoSpecimen();
    }

    Duration duration = (Duration) context.resolve(Duration.class);
    if (type.equals(Seconds.class)) return Seconds.seconds(Math.max(1, (int) duration.getStandardSeconds()));
    if (type.equals(Minutes.class)) return Minutes.minutes(Math.max(1, (int) duration.getStandardMinutes()));
    if (type.equals(Hours.class)) return Hours.hours(Math.max(1, (int) duration.getStandardHours()));

    if (type.equals(Days.class)) return Days.days(Math.max(1, (int) duration.getStandardDays()));
    if (type.equals(Weeks.class)) return Weeks.weeks(Math.max(1, (int) duration.getStandardDays() / 7));
    if (type.equals(Months.class)) return Months.months(Math.max(1, (int) duration.getStandardDays() / 30));
    if (type.equals(Years.class)) return Years.years(Math.max(1, (int) duration.getStandardDays() / 365));

    return new NoSpecimen();
}
 
开发者ID:FlexTradeUKLtd,项目名称:jfixture,代码行数:25,代码来源:BaseSingleFieldPeriodRelay.java

示例2: isVotingSuspended_is_true_if_votingInProgress_and_notEnoughSupport_and_minSupportDurationEnded

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void isVotingSuspended_is_true_if_votingInProgress_and_notEnoughSupport_and_minSupportDurationEnded() {

    int minSupportCountForSearch = 50;
    Days minSupportCountDuration = Days.days(1);

    initiativeInfo.setStartDate(TWO_DAYS_AGO);
    initiativeInfo.assignEndDate(TODAY);
    initiativeInfo.assignSupportCount(minSupportCountForSearch-1);

    // Assert that the state is what we wanted.
    assert(initiativeInfo.isVotingInProggress(TODAY));
    assert(!initiativeInfo.hasTotalSupportCountAtLeast(minSupportCountForSearch));
    assert(initiativeInfo.isMinSupportCountDurationEnded(minSupportCountDuration, TODAY));

    assertThat(initiativeInfo.isVotingSuspended(minSupportCountForSearch, minSupportCountDuration, TODAY), is(true));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:18,代码来源:InitiativeInfoTest.java

示例3: isVotingSuspended_is_false_if_votingNotInProgress

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void isVotingSuspended_is_false_if_votingNotInProgress() {

    int minSupportCountForSearch = 50;
    Days minSupportCountDuration = Days.days(1);

    initiativeInfo.setStartDate(TWO_DAYS_AGO);
    initiativeInfo.assignEndDate(YESTERDAY);
    initiativeInfo.assignSupportCount(minSupportCountForSearch-1);

    // Assert that the state is what we wanted.
    assert(!initiativeInfo.isVotingInProggress(TODAY));
    assert(!initiativeInfo.hasTotalSupportCountAtLeast(minSupportCountForSearch));
    assert(initiativeInfo.isMinSupportCountDurationEnded(minSupportCountDuration, TODAY));

    assertThat(initiativeInfo.isVotingSuspended(minSupportCountForSearch, minSupportCountDuration, TODAY), is(false));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:18,代码来源:InitiativeInfoTest.java

示例4: isVotingSuspended_is_false_if_has_required_minSupportCount

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void isVotingSuspended_is_false_if_has_required_minSupportCount() {

    int minSupportCountForSearch = 50;
    Days minSupportCountDuration = Days.days(1);

    initiativeInfo.setStartDate(TWO_DAYS_AGO);
    initiativeInfo.assignEndDate(TOMORROW);
    initiativeInfo.assignSupportCount(minSupportCountForSearch+1);

    // Assert that the state is what we wanted.
    assert(initiativeInfo.isVotingInProggress(TODAY));
    assert(initiativeInfo.hasTotalSupportCountAtLeast(minSupportCountForSearch));
    assert(initiativeInfo.isMinSupportCountDurationEnded(minSupportCountDuration, TODAY));

    assertThat(initiativeInfo.isVotingSuspended(minSupportCountForSearch, minSupportCountDuration, TODAY), is(false));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:18,代码来源:InitiativeInfoTest.java

示例5: isVotingSuspended_is_false_if_minSupportCountDuration_not_ended

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void isVotingSuspended_is_false_if_minSupportCountDuration_not_ended() {

    int minSupportCountForSearch = 50;
    Days minSupportCountDuration = Days.days(1);

    initiativeInfo.setStartDate(YESTERDAY);
    initiativeInfo.assignEndDate(TODAY);
    initiativeInfo.assignSupportCount(minSupportCountForSearch-1);

    // Assert that the state is what we wanted.
    assert(initiativeInfo.isVotingInProggress(TODAY));
    assert(!initiativeInfo.hasTotalSupportCountAtLeast(minSupportCountForSearch));
    assert(!initiativeInfo.isMinSupportCountDurationEnded(minSupportCountDuration, TODAY));

    assertThat(initiativeInfo.isVotingSuspended(minSupportCountForSearch, minSupportCountDuration, TODAY), is(false));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:18,代码来源:InitiativeInfoTest.java

示例6: initiativeSearch

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void find_with_show_only_running_does_not_show_if_not_enough_supports_and_minSupportCountDuration_has_ended() {
    testHelper.create(new TestHelper.InitiativeDraft(userId)
            .withState(InitiativeState.ACCEPTED)
            .withSupportCount(49)
            .isRunning(day_before_yesterday, far_in_the_future));

    Long hasEnoughtSupports = testHelper.create(new TestHelper.InitiativeDraft(userId)
            .withState(InitiativeState.ACCEPTED)
            .withSupportCount(50)
            .isRunning(day_before_yesterday, far_in_the_future));

    InitiativeSearch search = initiativeSearch();
    search.setShow(Show.running);

    InitiativeSettings.MinSupportCountSettings supportCountSettings
            = new InitiativeSettings.MinSupportCountSettings(50, Days.days(1)); // Ended yesterday
    List<InitiativeInfo> result = initiativeDao.findInitiatives(search, userId, supportCountSettings).list;

    assertThat(result.size(), is(1));
    assertThat(result.get(0).getId(), is(hasEnoughtSupports));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:23,代码来源:InitiativeDaoSearchTest.java

示例7: find_with_show_only_running_shows_if_not_enough_supports_and_if_time_has_not_ended_inclusive

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void find_with_show_only_running_shows_if_not_enough_supports_and_if_time_has_not_ended_inclusive() {
    testHelper.create(new TestHelper.InitiativeDraft(userId)
            .withState(InitiativeState.ACCEPTED)
            .withSupportCount(49)
            .isRunning(day_before_yesterday, far_in_the_future));

    testHelper.create(new TestHelper.InitiativeDraft(userId)
            .withState(InitiativeState.ACCEPTED)
            .withSupportCount(50)
            .isRunning(day_before_yesterday, far_in_the_future));

    InitiativeSearch search = initiativeSearch();
    search.setShow(Show.running);

    InitiativeSettings.MinSupportCountSettings supportCountSettings
            = new InitiativeSettings.MinSupportCountSettings(50, Days.days(2)); // Ending today, is inclusive
    List<InitiativeInfo> result = initiativeDao.findInitiatives(search, userId, supportCountSettings).list;

    assertThat(result.size(), is(2));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:22,代码来源:InitiativeDaoSearchTest.java

示例8: find_with_show_only_ended_shows_if_not_enough_supports_and_minSupportDuration_time_has_ended

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void find_with_show_only_ended_shows_if_not_enough_supports_and_minSupportDuration_time_has_ended() {
    Long notEnoughSupportsAndMinSupportTimeEnded = testHelper.create(new TestHelper.InitiativeDraft(userId)
            .withState(InitiativeState.ACCEPTED)
            .withSupportCount(49)
            .isRunning(day_before_yesterday, far_in_the_future));

    testHelper.create(new TestHelper.InitiativeDraft(userId)
            .withState(InitiativeState.ACCEPTED)
            .withSupportCount(50)
            .isRunning(day_before_yesterday, far_in_the_future));

    InitiativeSearch search = initiativeSearch();
    search.setShow(Show.ended);

    InitiativeSettings.MinSupportCountSettings supportCountSettings
            = new InitiativeSettings.MinSupportCountSettings(50, Days.days(1)); // Ended yesterday
    List<InitiativeInfo> result = initiativeDao.findInitiatives(search, userId, supportCountSettings).list;

    assertThat(result.size(), is(1));
    assertThat(result.get(0).getId(), is(notEnoughSupportsAndMinSupportTimeEnded));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:23,代码来源:InitiativeDaoSearchTest.java

示例9: parsePeriodString

import org.joda.time.Days; //导入方法依赖的package包/类
public static ReadablePeriod parsePeriodString(String periodStr) {
  ReadablePeriod period;
  char periodUnit = periodStr.charAt(periodStr.length() - 1);
  if (periodUnit == 'n') {
    return null;
  }

  int periodInt =
      Integer.parseInt(periodStr.substring(0, periodStr.length() - 1));
  switch (periodUnit) {
  case 'M':
    period = Months.months(periodInt);
    break;
  case 'w':
    period = Weeks.weeks(periodInt);
    break;
  case 'd':
    period = Days.days(periodInt);
    break;
  case 'h':
    period = Hours.hours(periodInt);
    break;
  case 'm':
    period = Minutes.minutes(periodInt);
    break;
  case 's':
    period = Seconds.seconds(periodInt);
    break;
  default:
    throw new IllegalArgumentException("Invalid schedule period unit '"
        + periodUnit);
  }

  return period;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:36,代码来源:Schedule.java

示例10: parsePeriodString

import org.joda.time.Days; //导入方法依赖的package包/类
public static ReadablePeriod parsePeriodString(String periodStr) {
  ReadablePeriod period;
  char periodUnit = periodStr.charAt(periodStr.length() - 1);
  if (periodStr.equals("null") || periodUnit == 'n') {
    return null;
  }

  int periodInt =
      Integer.parseInt(periodStr.substring(0, periodStr.length() - 1));
  switch (periodUnit) {
  case 'y':
    period = Years.years(periodInt);
    break;
  case 'M':
    period = Months.months(periodInt);
    break;
  case 'w':
    period = Weeks.weeks(periodInt);
    break;
  case 'd':
    period = Days.days(periodInt);
    break;
  case 'h':
    period = Hours.hours(periodInt);
    break;
  case 'm':
    period = Minutes.minutes(periodInt);
    break;
  case 's':
    period = Seconds.seconds(periodInt);
    break;
  default:
    throw new IllegalArgumentException("Invalid schedule period unit '"
        + periodUnit);
  }

  return period;
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:39,代码来源:Utils.java

示例11: resolve

import org.joda.time.Days; //导入方法依赖的package包/类
public LocalDateTime resolve(LocalDateTime base) {
  if (this.duration==null || this.durationUnit==null) {
    return null;
  }

  ReadablePeriod period = null;
  if (DAYS.equals(durationUnit)) {
    period = Days.days(getDurationAsInt());
  } else if (WEEKS.equals(durationUnit)) {
    period = Weeks.weeks(getDurationAsInt());
  } else if (HOURS.equals(durationUnit)) {
    period = Hours.hours(getDurationAsInt());
  } else if (MONTHS.equals(durationUnit)) {
    period = Months.months(getDurationAsInt());
  } else if (YEARS.equals(durationUnit)) {
    period = Years.years(getDurationAsInt());
  } else if (MINUTES.equals(durationUnit)) {
    period = Minutes.minutes(getDurationAsInt());
  } else {
    return null;
  }

  LocalDateTime time = base.plus(period);
  
  if (atHour!=null) {
    LocalDateTime atTime = time.withTime(atHour, atMinute!=null ? atMinute : 0, 0, 0);
    if (atTime.isBefore(time)) {
      time = atTime.plusDays(1);
    } else {
      time = atTime;
    }
  } else if (isDayResolutionOrBigger()) {
    time = time.withTime(23, 59, 59, 999);
  }
  
  return time;
}
 
开发者ID:effektif,项目名称:effektif,代码行数:38,代码来源:AfterRelativeTime.java

示例12: parsePeriodString

import org.joda.time.Days; //导入方法依赖的package包/类
public static ReadablePeriod parsePeriodString(String periodStr) {
	ReadablePeriod period;
	char periodUnit = periodStr.charAt(periodStr.length() - 1);
	if (periodUnit == 'n') {
		return null;
	}

	int periodInt = Integer.parseInt(periodStr.substring(0,
			periodStr.length() - 1));
	switch (periodUnit) {
	case 'M':
		period = Months.months(periodInt);
		break;
	case 'w':
		period = Weeks.weeks(periodInt);
		break;
	case 'd':
		period = Days.days(periodInt);
		break;
	case 'h':
		period = Hours.hours(periodInt);
		break;
	case 'm':
		period = Minutes.minutes(periodInt);
		break;
	case 's':
		period = Seconds.seconds(periodInt);
		break;
	default:
		throw new IllegalArgumentException("Invalid schedule period unit '"
				+ periodUnit);
	}

	return period;
}
 
开发者ID:zhizhounq,项目名称:azkaban-customization,代码行数:36,代码来源:Schedule.java

示例13: parsePeriodString

import org.joda.time.Days; //导入方法依赖的package包/类
public static ReadablePeriod parsePeriodString(String periodStr) {
	ReadablePeriod period;
	char periodUnit = periodStr.charAt(periodStr.length() - 1);
	if (periodStr.equals("null") || periodUnit == 'n') {
		return null;
	}

	int periodInt = Integer.parseInt(periodStr.substring(0,
			periodStr.length() - 1));
	switch (periodUnit) {
	case 'y':
		period = Years.years(periodInt);
		break;
	case 'M':
		period = Months.months(periodInt);
		break;
	case 'w':
		period = Weeks.weeks(periodInt);
		break;
	case 'd':
		period = Days.days(periodInt);
		break;
	case 'h':
		period = Hours.hours(periodInt);
		break;
	case 'm':
		period = Minutes.minutes(periodInt);
		break;
	case 's':
		period = Seconds.seconds(periodInt);
		break;
	default:
		throw new IllegalArgumentException("Invalid schedule period unit '"
				+ periodUnit);
	}

	return period;
}
 
开发者ID:zhizhounq,项目名称:azkaban-customization,代码行数:39,代码来源:Utils.java

示例14: isVotesRemovalEndDateNear_returns_true_if_date_in_given_scope

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void isVotesRemovalEndDateNear_returns_true_if_date_in_given_scope() {
    initiativeInfo.assignEndDate(TWO_DAYS_AGO);

    Days fourDayRemovalDuration = Days.days(4);
    assertThat(initiativeInfo.getEndDateForVotesRemoval(fourDayRemovalDuration), is(TWO_DAYS_LATER));
    assertThat(initiativeInfo.isVotesRemovalEndDateNear(TODAY, fourDayRemovalDuration, Days.days(3)), is(true));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:9,代码来源:InitiativeInfoTest.java

示例15: isVotesRemovalEndDateNear_returns_false_if_date_before_given_scope

import org.joda.time.Days; //导入方法依赖的package包/类
@Test
public void isVotesRemovalEndDateNear_returns_false_if_date_before_given_scope() {
    initiativeInfo.assignEndDate(TWO_DAYS_AGO);

    Days fourDayRemovalDuration = Days.days(4);
    assertThat(initiativeInfo.getEndDateForVotesRemoval(fourDayRemovalDuration), is(TWO_DAYS_LATER));
    assertThat(initiativeInfo.isVotesRemovalEndDateNear(TODAY, fourDayRemovalDuration, Days.days(1)), is(false));
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:9,代码来源:InitiativeInfoTest.java


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