List of usage examples for org.joda.time Period seconds
public static Period seconds(int seconds)
From source file:ch.ge.ve.offlineadmin.controller.BallotDecryptionController.java
License:Open Source License
private String formatElapsedTime(Stopwatch stopwatch) { Period period = Period.seconds((int) stopwatch.elapsed(TimeUnit.SECONDS)) // Need to normalize here so that 179 seconds will be seen as 2 minutes and 59 seconds .normalizedStandard();/*from www. j a v a2 s .com*/ return periodFormatter.print(period); }
From source file:com.arpnetworking.metrics.portal.alerts.impl.DatabaseAlertRepository.java
License:Apache License
private Alert convertFromEbeanAlert(final models.ebean.Alert ebeanAlert) { return new DefaultAlert.Builder().setCluster(ebeanAlert.getCluster()).setContext(ebeanAlert.getContext()) .setId(ebeanAlert.getUuid()).setMetric(ebeanAlert.getMetric()).setName(ebeanAlert.getName()) .setOperator(ebeanAlert.getOperator()).setPeriod(Period.seconds(ebeanAlert.getPeriod())) .setService(ebeanAlert.getService()).setStatistic(ebeanAlert.getStatistic()) .setValue(new DefaultQuantity.Builder().setValue(ebeanAlert.getQuantityValue()) .setUnit(ebeanAlert.getQuantityUnit()).build()) .setNagiosExtension(convertToInternalNagiosExtension(ebeanAlert.getNagiosExtension())).build(); }
From source file:com.nestedbird.components.bridges.JodaPeriodSplitBridge.java
License:Open Source License
@Override public Object get(final String name, final Document document) { final IndexableField stringPeriod = document.getField(name); if (stringPeriod != null) { return Period.seconds((Integer) stringPeriod.numericValue()); } else {/*w ww. ja v a 2s . c o m*/ return null; } }
From source file:com.nestedbird.models.eventtime.EventTime.java
License:Open Source License
/** * Sets duration./* w w w.java 2s . c o m*/ * * @param duration the duration * @return the duration */ public EventTime setDuration(final Integer duration) { this.duration = Period.seconds(duration); return this; }
From source file:com.nestedbird.models.eventtime.EventTime.java
License:Open Source License
/** * Sets repeat time./*from w w w . j a va 2 s . c o m*/ * * @param repeatTime the repeat time * @return the repeat time */ public EventTime setRepeatTime(final Integer repeatTime) { this.repeatTime = Period.seconds(repeatTime); return this; }
From source file:com.nestedbird.modules.formparser.FormParse.java
License:Open Source License
/** * Parse Period/*from www. jav a2 s . c o m*/ * * @param value value to parse * @return new Period */ private Period parsePeriod(final String value) { return Period.seconds(Integer.parseInt(value)); }
From source file:com.netflix.iep.config.Strings.java
License:Apache License
private static Period parseAtPeriod(String amt, String unit) { int v = Integer.valueOf(amt); if (unit.equals("s") || unit.equals("second") || unit.equals("seconds")) return Period.seconds(v); if (unit.equals("m") || unit.equals("min") || unit.equals("minute") || unit.equals("minutes")) return Period.minutes(v); if (unit.equals("h") || unit.equals("hour") || unit.equals("hours")) return Period.hours(v); if (unit.equals("d") || unit.equals("day") || unit.equals("days")) return Period.days(v); if (unit.equals("w") || unit.equals("wk") || unit.equals("week") || unit.equals("weeks")) return Period.weeks(v); if (unit.equals("month") || unit.equals("months")) return Period.months(v); if (unit.equals("y") || unit.equals("year") || unit.equals("years")) return Period.years(v); throw new IllegalArgumentException("unknown unit " + unit); }
From source file:com.serotonin.m2m2.Common.java
License:Open Source License
public static Period getPeriod(int periodType, int periods) { switch (periodType) { case TimePeriods.MILLISECONDS: return Period.millis(periods); case TimePeriods.SECONDS: return Period.seconds(periods); case TimePeriods.MINUTES: return Period.minutes(periods); case TimePeriods.HOURS: return Period.hours(periods); case TimePeriods.DAYS: return Period.days(periods); case TimePeriods.WEEKS: return Period.weeks(periods); case TimePeriods.MONTHS: return Period.months(periods); case TimePeriods.YEARS: return Period.years(periods); default:/*from ww w . ja va 2 s . c om*/ throw new ShouldNeverHappenException("Unsupported time period: " + periodType); } }
From source file:com.thinkbiganalytics.scheduler.util.TimerToCronExpression.java
License:Apache License
/** * Parse a timer string to a Joda time period * * @param timer a string indicating a time unit (i.e. 5 sec) * @param periodType the Period unit to use. *///www .java2 s.c om public static Period timerStringToPeriod(String timer, PeriodType periodType) { String cronString = null; Integer time = Integer.parseInt(StringUtils.substringBefore(timer, " ")); String units = StringUtils.substringAfter(timer, " ").toLowerCase(); //time to years,days,months,hours,min, sec Integer days = 0; Integer hours = 0; Integer min = 0; Integer sec = 0; Period p = null; if (units.startsWith("sec")) { p = Period.seconds(time); } else if (units.startsWith("min")) { p = Period.minutes(time); } else if (units.startsWith("hr") || units.startsWith("hour")) { p = Period.hours(time); } else if (units.startsWith("day")) { p = Period.days(time); } if (periodType != null) { p = p.normalizedStandard(periodType); } else { } return p; }
From source file:io.druid.indexing.jdbc.JDBCIndexTaskClient.java
License:Apache License
@VisibleForTesting RetryPolicyFactory createRetryPolicyFactory() { // Retries [numRetries] times before giving up; this should be set long enough to handle any temporary // unresponsiveness such as network issues, if a task is still in the process of starting up, or if the task is in // the middle of persisting to disk and doesn't respond immediately. return new RetryPolicyFactory(new RetryPolicyConfig().setMinWait(Period.seconds(MIN_RETRY_WAIT_SECONDS)) .setMaxWait(Period.seconds(MAX_RETRY_WAIT_SECONDS)).setMaxRetryCount(numRetries)); }