Example usage for java.time LocalTime of

List of usage examples for java.time LocalTime of

Introduction

In this page you can find the example usage for java.time LocalTime of.

Prototype

public static LocalTime of(int hour, int minute) 

Source Link

Document

Obtains an instance of LocalTime from an hour and minute.

Usage

From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java

@Override
public void executeStopResourceJob(boolean isAppliedForClusters) {
    OffsetDateTime currentDateTime = OffsetDateTime.now();
    List<SchedulerJobData> jobsToStop = getSchedulerJobsForAction(STOPPED, currentDateTime,
            isAppliedForClusters);/*www. j  ava2 s  . c  om*/
    if (!jobsToStop.isEmpty()) {
        log.debug(isAppliedForClusters ? "Scheduler computational resource stop job is executing..."
                : "Scheduler exploratory stop job is executing...");
        log.info(CURRENT_DATETIME_INFO,
                LocalTime.of(currentDateTime.toLocalTime().getHour(),
                        currentDateTime.toLocalTime().getMinute()),
                currentDateTime.toLocalDate(), currentDateTime.getDayOfWeek());
        log.info(isAppliedForClusters ? "Quantity of clusters for stopping: {}"
                : "Quantity of exploratories for stopping: {}", jobsToStop.size());
        jobsToStop.forEach(job -> changeResourceStatusTo(STOPPED, job, isAppliedForClusters));
    }
}

From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java

@Override
public void executeTerminateResourceJob(boolean isAppliedForClusters) {
    OffsetDateTime currentDateTime = OffsetDateTime.now();
    List<SchedulerJobData> jobsToTerminate = getSchedulerJobsForAction(UserInstanceStatus.TERMINATED,
            currentDateTime, isAppliedForClusters);
    if (!jobsToTerminate.isEmpty()) {
        log.debug(isAppliedForClusters ? "Scheduler computational resource terminate job is executing..."
                : "Scheduler exploratory terminate job is executing...");
        log.info(CURRENT_DATETIME_INFO,/*from  ww  w  .j a  v a  2s .c  o  m*/
                LocalTime.of(currentDateTime.toLocalTime().getHour(),
                        currentDateTime.toLocalTime().getMinute()),
                currentDateTime.toLocalDate(), currentDateTime.getDayOfWeek());
        log.info(isAppliedForClusters ? "Quantity of clusters for terminating: {}"
                : "Quantity of exploratories for terminating: {}", jobsToTerminate.size());
        jobsToTerminate.forEach(
                job -> changeResourceStatusTo(UserInstanceStatus.TERMINATED, job, isAppliedForClusters));
    }
}

From source file:org.vaadin.peholmst.samples.dddwebinar.TestDataGenerator.java

private static LocalTime randomTime() {
    return LocalTime.of(8 + RND.nextInt(10), 5 * RND.nextInt(12));
}

From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java

/**
 * Checks if scheduler's time data satisfies existing time parameters.
 *
 * @param dto           scheduler job data.
 * @param dateTime      existing time data.
 * @param desiredStatus target exploratory status which has influence for time/date checking ('running' status
 *                      requires for checking start time, 'stopped' - for end time, 'terminated' - for
 *                      'terminatedDateTime').
 * @return true/false./*from w w  w.  ja v  a 2  s .c  om*/
 */
private boolean isSchedulerJobDtoSatisfyCondition(SchedulerJobDTO dto, OffsetDateTime dateTime,
        UserInstanceStatus desiredStatus) {
    ZoneOffset zOffset = dto.getTimeZoneOffset();
    OffsetDateTime roundedDateTime = OffsetDateTime.of(dateTime.toLocalDate(),
            LocalTime.of(dateTime.toLocalTime().getHour(), dateTime.toLocalTime().getMinute()),
            dateTime.getOffset());

    LocalDateTime convertedDateTime = ZonedDateTime
            .ofInstant(roundedDateTime.toInstant(), ZoneId.ofOffset(TIMEZONE_PREFIX, zOffset))
            .toLocalDateTime();

    return desiredStatus == TERMINATED
            ? Objects.nonNull(dto.getTerminateDateTime())
                    && convertedDateTime.toLocalDate().equals(dto.getTerminateDateTime().toLocalDate())
                    && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus))
            : !convertedDateTime.toLocalDate().isBefore(dto.getBeginDate())
                    && isFinishDateMatchesCondition(dto, convertedDateTime)
                    && getDaysRepeat(dto, desiredStatus)
                            .contains(convertedDateTime.toLocalDate().getDayOfWeek())
                    && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus));
}

From source file:squash.booking.lambdas.core.PageManager.java

private List<String> getTimeSlotLabels() {

    // First time slot of the day is 10am...
    // ...so initialise to one time slot (i.e. 45 minutes) earlier
    logger.log("About to get time slot labels");
    LocalTime time = LocalTime.of(9, 15);
    List<String> timeSlots = new ArrayList<>();
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mm a");
    for (int slots = 1; slots <= 16; slots++) {
        time = time.plusMinutes(45);// ww  w .j a va2 s. c om
        timeSlots.add(time.format(formatter));
    }
    logger.log("Got slot labels: " + timeSlots);

    return timeSlots;
}

From source file:jmri.jmrix.loconet.messageinterp.LocoNetMessageInterpret.java

/**
 * Return a string which is formatted by a bundle Resource Name.
 *
 * @param hour    fast-clock hour/*from  w  ww .  j a  va 2  s  . c om*/
 * @param minute  fast-clock minute
 * @return a formatted string containing the time
 */
private static String fcTimeToString(int hour, int minute) {
    return Bundle.getMessage("LN_MSG_SLOT_HELPER_FC_TIME", LocalTime.of(hour, minute).toString());
}

From source file:net.tradelib.core.Series.java

static public Series fromDailyCsv(String path, boolean header) throws Exception {
    return fromCsv(path, header, DateTimeFormatter.ofPattern("yyyy-MM-dd"), LocalTime.of(17, 0));
}

From source file:org.darkware.wpman.util.TimeWindow.java

/**
 * Calculates the next time when a given hour and minute occur, based from the given start time.
 *
 * @param after The time to start searching from.
 * @param hour The hour to search for.//from w  w w .ja  v a  2  s. com
 * @param minute The minute to search for.
 * @return A {@code DateTime} corresponding to the hour and minute declared which is explicitly after
 * the start time.
 */
public static LocalDateTime nextTime(final LocalDateTime after, final int hour, final int minute) {
    LocalTime time = LocalTime.of(hour, minute);
    LocalDate afterDate = after.toLocalDate();
    if (!time.isAfter(after.toLocalTime()))
        afterDate = afterDate.plus(1, ChronoUnit.DAYS);
    return time.atDate(afterDate);
}

From source file:org.jgrades.lic.app.utils.LicenceBuilder.java

public LicenceBuilder withStartOfValid(LocalDate fromDateTime) {
    if (Optional.ofNullable(fromDateTime).isPresent() && !StringUtils.isEmpty(fromDateTime.toString())) {
        product.setValidFrom(LocalDateTime.of(fromDateTime, LocalTime.of(0, 0)));
    }//from  w  ww  .j  av  a2 s.  c  om
    return this;
}

From source file:org.jgrades.lic.app.utils.LicenceBuilder.java

public LicenceBuilder withEndOfValid(LocalDate toDateTime) {
    if (Optional.ofNullable(toDateTime).isPresent() && !StringUtils.isEmpty(toDateTime.toString())) {
        product.setValidTo(LocalDateTime.of(toDateTime, LocalTime.of(0, 0)));
    }//from   w  ww  .j a v a  2  s.  com
    return this;
}