Example usage for org.joda.time DateTime withPeriodAdded

List of usage examples for org.joda.time DateTime withPeriodAdded

Introduction

In this page you can find the example usage for org.joda.time DateTime withPeriodAdded.

Prototype

public DateTime withPeriodAdded(ReadablePeriod period, int scalar) 

Source Link

Document

Returns a copy of this datetime with the specified period added.

Usage

From source file:com.thinkbiganalytics.metadata.core.sla.WithinScheduleAssessor.java

License:Apache License

@Override
public void assess(WithinSchedule metric, MetricAssessmentBuilder<Serializable> builder) {
    DateTime start = new DateTime(CronExpressionUtil.getPreviousFireTime(metric.getCronExpression()));
    DateTime end = start.withPeriodAdded(metric.getPeriod(), 1);

    builder.metric(metric);//  www  . j a va 2s.c  om

    if (start.isBeforeNow() && end.isAfterNow()) {
        builder.result(AssessmentResult.SUCCESS)
                .message("Current time falls between the schedule " + start + " - " + end);
    } else {
        builder.result(AssessmentResult.FAILURE)
                .message("Current time does not falls between the schedule " + start + " - " + end);
    }
}