Example usage for org.joda.time Period plusSeconds

List of usage examples for org.joda.time Period plusSeconds

Introduction

In this page you can find the example usage for org.joda.time Period plusSeconds.

Prototype

public Period plusSeconds(int seconds) 

Source Link

Document

Returns a new period plus the specified number of seconds added.

Usage

From source file:com.planyourexchange.utils.DateUtils.java

License:Open Source License

public static Period sum(Period timeTotal, LocalTime... locatimes) {
    for (LocalTime time : locatimes) {
        timeTotal = timeTotal.plusHours(time.getHourOfDay());
        timeTotal = timeTotal.plusMinutes(time.getMinuteOfHour());
        timeTotal = timeTotal.plusSeconds(time.getSecondOfMinute());
    }/* w  ww .j  a  v  a 2 s .  com*/
    return timeTotal;
}

From source file:ddf.catalog.filter.proxy.adapter.PeriodParser.java

License:Open Source License

public static Period parse(@NotNull String periodText, Pattern regex) {

    Matcher matcher = regex.matcher(periodText);
    if (matcher.matches()) {
        long[] unitDurationsInSeconds = getUnitDurationsInSeconds();
        BigDecimal[] fullDecimalValues = parseFullDecimalValues(periodText, matcher);
        int[] roundedValues = roundValuesDownToNearestInt(fullDecimalValues);
        int sumOfFractionalValuesInSeconds = sumOfFractionalValuesInSeconds(fullDecimalValues,
                unitDurationsInSeconds);

        Period period = new Period(roundedValues[0], roundedValues[1], roundedValues[2], roundedValues[3],
                roundedValues[4], roundedValues[5], roundedValues[6], 0);

        return period.plusSeconds(sumOfFractionalValuesInSeconds);
    } else {/*  www .j ava2  s  .c  o m*/
        throw new IllegalArgumentException("Period not in valid format: " + periodText);
    }
}

From source file:org.jevis.application.unit.SampleRateNode.java

License:Open Source License

private void setPeriod(TextField field) {
    Period newPeriod = Period.ZERO;

    if (sliderMinutes.getValue() != 0) {
        newPeriod = newPeriod.plusMinutes((int) sliderMinutes.getValue());
    }// w  w  w  .  j  av a2 s .co  m
    if (sliderSecounds.getValue() != 0) {
        newPeriod = newPeriod.plusSeconds((int) sliderSecounds.getValue());
    }
    if (sliderHours.getValue() != 0) {
        newPeriod = newPeriod.plusHours((int) sliderHours.getValue());
    }
    if (sliderMonth.getValue() != 0) {
        newPeriod = newPeriod.plusMonths((int) sliderMonth.getValue());
    }
    if (sliderWeek.getValue() != 0) {
        newPeriod = newPeriod.plusWeeks((int) sliderWeek.getValue());
    }

    field.setText(newPeriod.toString());
    _returnPeriod = newPeriod;
}