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