Java Code Examples for java.time.LocalTime#withHour()

The following examples show how to use java.time.LocalTime#withHour() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKLocalTime.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 2
Source File: TCKLocalTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 3
Source File: TCKLocalTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 4
Source File: TCKLocalTime.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 5
Source File: TCKLocalTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 6
Source File: TCKLocalTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 7
Source File: TCKLocalTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 8
Source File: TCKLocalTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 9
Source File: TCKLocalTime.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 10
Source File: TCKLocalTime.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 11
Source File: TCKLocalTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 12
Source File: CubaTimeFieldWrapper.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected static AmPmLocalTime convertTo12hFormat(LocalTime time) {
    checkNotNull(time, "Unable to convert null value to 12h format");

    int hour = time.getHour() == 0 || time.getHour() == 12
            ? 12 : time.getHour() % 12;
    AmPm amPm = time.getHour() < 12
            ? AmPm.AM : AmPm.PM;
    return new AmPmLocalTime(time.withHour(hour), amPm);
}
 
Example 13
Source File: CubaTimeField.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected LocalTime applyResolutionToValue(LocalTime value) {
    if (value == null) {
        return null;
    }

    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;
}
 
Example 14
Source File: TCKLocalTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 15
Source File: TCKLocalTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}
 
Example 16
Source File: TCKLocalTime.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void test_withHour_normal() {
    LocalTime t = TEST_12_30_40_987654321;
    for (int i = 0; i < 24; i++) {
        t = t.withHour(i);
        assertEquals(t.getHour(), i);
    }
}