Example usage for java.time.temporal ChronoField HOUR_OF_DAY

List of usage examples for java.time.temporal ChronoField HOUR_OF_DAY

Introduction

In this page you can find the example usage for java.time.temporal ChronoField HOUR_OF_DAY.

Prototype

ChronoField HOUR_OF_DAY

To view the source code for java.time.temporal ChronoField HOUR_OF_DAY.

Click Source Link

Document

The hour-of-day.

Usage

From source file:msi.gama.util.GamaDate.java

@getter("hour")
public int getHour() {
    return internal.get(ChronoField.HOUR_OF_DAY);
}

From source file:com.thinkbiganalytics.integration.IntegrationTestBase.java

private ServiceLevelAgreementGroup createFeedProcessingDeadlineSla(String feedName, String feedId,
        LocalDateTime deadline, String noLaterThanHours) {
    int hourOfDay = deadline.get(ChronoField.HOUR_OF_DAY);
    int minuteOfHour = deadline.get(ChronoField.MINUTE_OF_HOUR);
    String cronExpression = String.format("0 %s %s 1/1 * ? *", minuteOfHour, hourOfDay);

    ServiceLevelAgreementGroup sla = new ServiceLevelAgreementGroup();
    String time = deadline.format(DateTimeFormatter.ofPattern("HH:mm"));
    sla.setName("Before " + time + " (cron: " + cronExpression + ")");
    sla.setDescription("The feed should complete before given date and time");
    List<ServiceLevelAgreementRule> rules = new ArrayList<>();
    ServiceLevelAgreementRule rule = new ServiceLevelAgreementRule();
    rule.setName("Feed Processing deadline");
    rule.setDisplayName("Feed Processing deadline");
    rule.setDescription("Ensure a Feed processes data by a specified time");
    rule.setObjectClassType("com.thinkbiganalytics.metadata.sla.api.core.FeedOnTimeArrivalMetric");
    rule.setObjectShortClassType("FeedOnTimeArrivalMetric");
    rule.setCondition(ObligationGroup.Condition.REQUIRED);

    rule.setProperties(newFieldRuleProperties(newFieldRuleProperty("FeedName", "feedName", feedName),
            newFieldRuleProperty("ExpectedDeliveryTime", "cronString", cronExpression),
            newFieldRuleProperty("NoLaterThanTime", "lateTime", noLaterThanHours),
            newFieldRuleProperty("NoLaterThanUnits", "lateUnits", "hrs")));

    rules.add(rule);//from w w  w.  ja v a  2 s  .c o  m
    sla.setRules(rules);

    Response response = given(ServiceLevelAgreementRestController.V1_FEEDMGR_SLA).body(sla).when()
            .post(String.format("feed/%s", feedId));

    response.then().statusCode(HTTP_OK);

    return response.as(ServiceLevelAgreementGroup.class);
}

From source file:onl.area51.gfs.grib2.job.GribRetriever.java

/**
 * Convert a {@link LocalDateTime} to a GFS run time. Specifically this is the date and hour of the day restricted to 0, 7, 12 or 18 hours.
 * <p>/*from w ww.  ja  v a  2s. c o  m*/
 * @param date date
 * <p>
 * @return date modified to the nearest GFS run (earlier than date) or null if date was null
 */
public static LocalDateTime toGFSRunTime(LocalDateTime date) {
    if (date == null) {
        return null;
    }

    LocalDateTime dateTime = date.truncatedTo(ChronoUnit.HOURS);

    // Only allow hours 0, 6, 12 & 18
    int h = dateTime.get(ChronoField.HOUR_OF_DAY);
    if (h % 6 == 0) {
        return dateTime;
    }

    return dateTime.withHour((h / 6) * 6);
}