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


Java Hours.hours方法代碼示例

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


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

示例1: create

import org.joda.time.Hours; //導入方法依賴的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: parsePeriodString

import org.joda.time.Hours; //導入方法依賴的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

示例3: parsePeriodString

import org.joda.time.Hours; //導入方法依賴的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

示例4: resolve

import org.joda.time.Hours; //導入方法依賴的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

示例5: parsePeriodString

import org.joda.time.Hours; //導入方法依賴的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

示例6: parsePeriodString

import org.joda.time.Hours; //導入方法依賴的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

示例7: setValue

import org.joda.time.Hours; //導入方法依賴的package包/類
@Override
public void setValue(Object value) {
    if (value == null || value instanceof Hours) {
        super.setValue(value);
    } else if (value instanceof Number) {
        super.setValue(Hours.hours(abs(((Number) value).intValue())));
    } else {
        throw new IllegalArgumentException("Invalid value " + value);
    }
}
 
開發者ID:griffon-legacy,項目名稱:griffon-scaffolding-plugin,代碼行數:11,代碼來源:HoursValue.java

示例8: updateSchedules

import org.joda.time.Hours; //導入方法依賴的package包/類
public void updateSchedules(Reportal report, ScheduleManager scheduleManager,
    User user, Flow flow) throws ScheduleManagerException {
  // Clear previous schedules
  removeSchedules(scheduleManager);
  // Add new schedule
  if (schedule) {
    int hour =
        (Integer.parseInt(scheduleHour) % 12)
            + (scheduleAmPm.equalsIgnoreCase("pm") ? 12 : 0);
    int minute = Integer.parseInt(scheduleMinute) % 60;
    DateTimeZone timeZone =
        scheduleTimeZone.equalsIgnoreCase("UTC") ? DateTimeZone.UTC
            : DateTimeZone.getDefault();
    DateTime firstSchedTime =
        DateTimeFormat.forPattern("MM/dd/yyyy").withZone(timeZone)
            .parseDateTime(scheduleDate);
    firstSchedTime =
        firstSchedTime.withHourOfDay(hour).withMinuteOfHour(minute)
            .withSecondOfMinute(0).withMillisOfSecond(0);

    ReadablePeriod period = null;
    if (scheduleRepeat) {
      int intervalQuantity = Integer.parseInt(scheduleIntervalQuantity);

      if (scheduleInterval.equals("y")) {
        period = Years.years(intervalQuantity);
      } else if (scheduleInterval.equals("m")) {
        period = Months.months(intervalQuantity);
      } else if (scheduleInterval.equals("w")) {
        period = Weeks.weeks(intervalQuantity);
      } else if (scheduleInterval.equals("d")) {
        period = Days.days(intervalQuantity);
      } else if (scheduleInterval.equals("h")) {
        period = Hours.hours(intervalQuantity);
      } else if (scheduleInterval.equals("M")) {
        period = Minutes.minutes(intervalQuantity);
      }
    }

    ExecutionOptions options = new ExecutionOptions();
    options.getFlowParameters().put("reportal.execution.user",
        user.getUserId());
    options.getFlowParameters().put("reportal.title", report.title);
    options.getFlowParameters().put("reportal.render.results.as.html",
        report.renderResultsAsHtml ? "true" : "false");
    options.setMailCreator(ReportalMailCreator.REPORTAL_MAIL_CREATOR);

    long endScheduleTime = report.endSchedule == null ?
        DEFAULT_SCHEDULE_END_EPOCH_TIME: parseDateToEpoch(report.endSchedule);

    logger.info("This report scheudle end time is " + endScheduleTime);

    scheduleManager.scheduleFlow(-1, project.getId(), project.getName(),
        flow.getId(), "ready", firstSchedTime.getMillis(), endScheduleTime,
        firstSchedTime.getZone(), period, DateTime.now().getMillis(),
        firstSchedTime.getMillis(), firstSchedTime.getMillis(),
        user.getUserId(), options, null);
  }
}
 
開發者ID:azkaban,項目名稱:azkaban-plugins,代碼行數:60,代碼來源:Reportal.java


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