Example usage for java.time LocalTime withMinute

List of usage examples for java.time LocalTime withMinute

Introduction

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

Prototype

public LocalTime withMinute(int minute) 

Source Link

Document

Returns a copy of this LocalTime with the minute-of-hour altered.

Usage

From source file:com.haulmont.cuba.web.widgets.CubaTimeField.java

protected LocalTime applyResolutionToValue(LocalTime value) {
    if (value == null) {
        return null;
    }//from  w w w  . j a  v  a 2  s.  c o  m

    LocalTime result = LocalTime.MIDNIGHT;
    List<TimeResolution> resolutions = getResolutionsHigherOrEqualTo(getResolution())
            .collect(Collectors.toList());

    for (TimeResolution resolution : resolutions) {
        switch (resolution) {
        case HOUR:
            result = result.withHour(value.getHour());
            break;
        case MINUTE:
            result = result.withMinute(value.getMinute());
            break;
        case SECOND:
            result = result.withSecond(value.getSecond());
            break;
        default:
            throw new IllegalArgumentException("Cannot detect resolution type");
        }
    }

    return result;
}