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

The following examples show how to use java.time.LocalTime#plusSeconds() . 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 jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusSeconds_one() {
    LocalTime t = LocalTime.MIDNIGHT;
    int hour = 0;
    int min = 0;
    int sec = 0;
    for (int i = 0; i < 3700; i++) {
        t = t.plusSeconds(1);
        sec++;
        if (sec == 60) {
            min++;
            sec = 0;
        }
        if (min == 60) {
            hour++;
            min = 0;
        }
        assertEquals(t.getHour(), hour);
        assertEquals(t.getMinute(), min);
        assertEquals(t.getSecond(), sec);
    }
}
 
Example 2
Source File: TCKLocalTime.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusSeconds_one() {
    LocalTime t = LocalTime.MIDNIGHT;
    int hour = 0;
    int min = 0;
    int sec = 0;
    for (int i = 0; i < 3700; i++) {
        t = t.plusSeconds(1);
        sec++;
        if (sec == 60) {
            min++;
            sec = 0;
        }
        if (min == 60) {
            hour++;
            min = 0;
        }
        assertEquals(t.getHour(), hour);
        assertEquals(t.getMinute(), min);
        assertEquals(t.getSecond(), sec);
    }
}
 
Example 3
Source File: TCKLocalTime.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusSeconds_one() {
    LocalTime t = LocalTime.MIDNIGHT;
    int hour = 0;
    int min = 0;
    int sec = 0;
    for (int i = 0; i < 3700; i++) {
        t = t.plusSeconds(1);
        sec++;
        if (sec == 60) {
            min++;
            sec = 0;
        }
        if (min == 60) {
            hour++;
            min = 0;
        }
        assertEquals(t.getHour(), hour);
        assertEquals(t.getMinute(), min);
        assertEquals(t.getSecond(), sec);
    }
}
 
Example 4
Source File: TCKLocalTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
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_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
Example 6
Source File: TCKLocalTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="plusSeconds_fromZero")
public void test_plusSeconds_fromZero(int seconds, int hour, int min, int sec) {
    LocalTime base = LocalTime.MIDNIGHT;
    LocalTime t = base.plusSeconds(seconds);

    assertEquals(hour, t.getHour());
    assertEquals(min, t.getMinute());
    assertEquals(sec, t.getSecond());
}
 
Example 7
Source File: TCKLocalTime.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="plusSeconds_fromZero")
public void test_plusSeconds_fromZero(int seconds, int hour, int min, int sec) {
    LocalTime base = LocalTime.MIDNIGHT;
    LocalTime t = base.plusSeconds(seconds);

    assertEquals(hour, t.getHour());
    assertEquals(min, t.getMinute());
    assertEquals(sec, t.getSecond());
}
 
Example 8
Source File: TCKLocalTime.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
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_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
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_toSecondOfDay() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(t.toSecondOfDay(), i);
        t = t.plusSeconds(1);
    }
}
 
Example 11
Source File: TCKLocalTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
Example 12
Source File: TCKLocalTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(t.toSecondOfDay(), i);
        t = t.plusSeconds(1);
    }
}
 
Example 13
Source File: TCKLocalTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
Example 14
Source File: TCKLocalTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
Example 15
Source File: TCKLocalTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
Example 16
Source File: TCKLocalTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(t.toSecondOfDay(), i);
        t = t.plusSeconds(1);
    }
}
 
Example 17
Source File: TCKLocalTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="plusSeconds_fromZero")
public void test_plusSeconds_fromZero(int seconds, int hour, int min, int sec) {
    LocalTime base = LocalTime.MIDNIGHT;
    LocalTime t = base.plusSeconds(seconds);

    assertEquals(hour, t.getHour());
    assertEquals(min, t.getMinute());
    assertEquals(sec, t.getSecond());
}
 
Example 18
Source File: TCKLocalTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(t.toSecondOfDay(), i);
        t = t.plusSeconds(1);
    }
}
 
Example 19
Source File: TCKLocalTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_toSecondOfDay_fromNanoOfDay_symmetry() {
    LocalTime t = LocalTime.of(0, 0);
    for (int i = 0; i < 24 * 60 * 60; i++) {
        assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
        t = t.plusSeconds(1);
    }
}
 
Example 20
Source File: DateTimeExtensions.java    From groovy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a {@link java.time.LocalTime} that is {@code seconds} seconds after this time.
 *
 * @param self    a LocalTime
 * @param seconds the number of seconds to add
 * @return a LocalTime
 * @since 2.5.0
 */
public static LocalTime plus(final LocalTime self, long seconds) {
    return self.plusSeconds(seconds);
}