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


Java Seconds.seconds方法代碼示例

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


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

示例1: create

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

import org.joda.time.Seconds; //導入方法依賴的package包/類
/**
 * Adding this wait as the Sybase ASE logs can fill up quickly if you execute a lot of DDLs
 * Hence, we put in a periodic check (currently going by every "maxLogCounter" updates executed)
 * to see if the log level exceeds a "stopLogSpaceThreshold". If so, we wait till it gets back
 * down to a "resumeLogSpaceThreshold"
 */
private void waitForLogSpace(Connection conn, JdbcHelper jdbc) {
    this.curLogCounter.incrementAndGet();

    // only trigger the check every "maxLogCounter" checks
    if (this.curLogCounter.get() == maxLogCounter) {
        boolean firstTime = true;

        while (true) {
            int percentFull = getPercentLogFullInDb(conn, jdbc);

            int thresholdToCheck = firstTime ? stopLogSpaceThreshold : resumeLogSpaceThreshold;
            firstTime = false;

            if (percentFull < thresholdToCheck) {
                break;
            } else {
                try {
                    Seconds seconds = Seconds.seconds(3);
                    LOG.info(String
                            .format("Pausing for %d seconds as the log level hit a high mark of %d; will resume when it gets back to %d",
                                    seconds.getSeconds(), percentFull, resumeLogSpaceThreshold));
                    Thread.sleep(seconds.getSeconds() * 1000);
                } catch (InterruptedException e) {
                    throw new DeployerRuntimeException(e);
                }
            }
        }

        this.curLogCounter.set(0);  // reset the log counter after doing the check
    } else if (this.curLogCounter.get() > maxLogCounter) {
        // in this case, some concurrent execution caused the ID to exceed the maxLogCounter. In this case, just
        // reset the counter to 0 (the thread that has the counter at the right value would execute this code
        this.curLogCounter.set(0);
    }
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:42,代碼來源:AseSqlExecutor.java

示例3: parsePeriodString

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

示例4: parsePeriodString

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

示例5: getFormattedDuration

import org.joda.time.Seconds; //導入方法依賴的package包/類
private String getFormattedDuration(int seconds) {
    Period period = new Period(Seconds.seconds(seconds));

    PeriodFormatter periodFormatter = new PeriodFormatterBuilder()
            .printZeroAlways()
            .minimumPrintedDigits(2)
            .appendHours()
            .appendSeparator(":")
            .appendMinutes()
            .appendSeparator(":")
            .appendSeconds()
            .toFormatter();

    return periodFormatter.print(period.normalizedStandard());
}
 
開發者ID:mbStavola,項目名稱:FriendCaster,代碼行數:16,代碼來源:FeedRecyclerAdapter.java

示例6: assertTimeValid

import org.joda.time.Seconds; //導入方法依賴的package包/類
private void assertTimeValid(JSONObject payload) throws JwtVerifyException {
    Seconds currentTime = Seconds.seconds((int) (DateTime.now().getMillis() / DateTimeConstants.MILLIS_PER_SECOND));

    Seconds issueTime = Seconds.seconds(((Long) payload.get(JwtClaims.ISSUED_AT)).intValue());
    if (issueTime.isGreaterThan(currentTime.plus(TIME_BUFFER_IN_SECONDS))) {
        LOGGER.warn(ISSUE_TIME_EXCEPTION, issueTime, currentTime);
        throw new JwtVerifyException(ISSUE_TIME_EXCEPTION, issueTime, currentTime);
    }

    if (payload.get(JwtClaims.NOT_BEFORE) != null) {
        Seconds notBeforeTime = Seconds.seconds(((Long) payload.get(JwtClaims.NOT_BEFORE)).intValue());
        if (currentTime.isLessThan(notBeforeTime.minus(TIME_BUFFER_IN_SECONDS))) {
            LOGGER.warn(format(NOT_BEFORE_EXCEPTION, notBeforeTime, currentTime));
            throw new JwtVerifyException(NOT_BEFORE_EXCEPTION, notBeforeTime, currentTime);
        }
    }

    if (payload.get(JwtClaims.EXPIRATION_TIME) != null) {
        Seconds expTime = Seconds.seconds(((Long) payload.get(JwtClaims.EXPIRATION_TIME)).intValue());
        if (expTime.isLessThan(currentTime.minus(TIME_BUFFER_IN_SECONDS))) {
            LOGGER.warn(format(EXP_TIME_EXCEPTION, expTime, currentTime));
            throw new JwtVerifyException(EXP_TIME_EXCEPTION, expTime, currentTime);
        }
        if (expTime.isLessThan(issueTime)) {
            LOGGER.warn(format(TIME_RANGE_EXCEPTION, expTime, issueTime));
            throw new JwtVerifyException(TIME_RANGE_EXCEPTION, expTime, issueTime);
        }
    }
}
 
開發者ID:wdawson,項目名稱:dropwizard-auth-example,代碼行數:30,代碼來源:JwtVerifier.java

示例7: parsePeriodString

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

示例8: parsePeriodString

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

示例9: setValue

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

示例10: evaluate

import org.joda.time.Seconds; //導入方法依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	checkArguments(arguments, 1);

	LocalTime instant = (arguments.get(0)).asLocalTime();

	Seconds seconds = Seconds.seconds(instant.getHourOfDay() * 60 * 60 + instant.getMinuteOfHour() * 60 + instant.getSecondOfMinute());

	SecondsSinceMidnight period = new SecondsSinceMidnight(seconds);

	return FieldValueUtil.create(DataType.INTEGER, OpType.CONTINUOUS, period.intValue());
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:13,代碼來源:Functions.java


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