Java Code Examples for java.time.LocalTime#minusSeconds()
The following examples show how to use
java.time.LocalTime#minusSeconds() .
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: TCKZonedDateTime.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); ZonedDateTime test = ZonedDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); assertEquals(test.getZone(), ZoneOffset.UTC); } }
Example 2
Source File: TCKZonedDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); ZonedDateTime test = ZonedDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); assertEquals(test.getZone(), ZoneOffset.UTC); } }
Example 3
Source File: TCKZonedDateTime.java From hottub with GNU General Public License v2.0 | 6 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); ZonedDateTime test = ZonedDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); assertEquals(test.getZone(), ZoneOffset.UTC); } }
Example 4
Source File: TCKLocalTime.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusSeconds_fromZero") public void test_minusSeconds_fromZero(int seconds, int hour, int min, int sec) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.minusSeconds(seconds); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); }
Example 5
Source File: TCKLocalTime.java From j2objc with Apache License 2.0 | 5 votes |
@Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; int min = 0; int sec = 0; for (int i = 0; i < 3700; i++) { t = t.minusSeconds(1); sec--; if (sec == -1) { min--; sec = 59; if (min == -1) { hour--; min = 59; if (hour == -1) { hour = 23; } } } assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); } }
Example 6
Source File: TCKLocalTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; int min = 0; int sec = 0; for (int i = 0; i < 3700; i++) { t = t.minusSeconds(1); sec--; if (sec == -1) { min--; sec = 59; if (min == -1) { hour--; min = 59; if (hour == -1) { hour = 23; } } } assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); } }
Example 7
Source File: TCKOffsetDateTime.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); OffsetDateTime test = OffsetDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); } }
Example 8
Source File: TCKLocalTime.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusSeconds_fromZero") public void test_minusSeconds_fromZero(int seconds, int hour, int min, int sec) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.minusSeconds(seconds); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); }
Example 9
Source File: TCKLocalTime.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; int min = 0; int sec = 0; for (int i = 0; i < 3700; i++) { t = t.minusSeconds(1); sec--; if (sec == -1) { min--; sec = 59; if (min == -1) { hour--; min = 59; if (hour == -1) { hour = 23; } } } assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); } }
Example 10
Source File: TCKOffsetDateTime.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); OffsetDateTime test = OffsetDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); } }
Example 11
Source File: TCKOffsetDateTime.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); OffsetDateTime test = OffsetDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); } }
Example 12
Source File: TCKLocalTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; int min = 0; int sec = 0; for (int i = 0; i < 3700; i++) { t = t.minusSeconds(1); sec--; if (sec == -1) { min--; sec = 59; if (min == -1) { hour--; min = 59; if (hour == -1) { hour = 23; } } } assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); } }
Example 13
Source File: TCKOffsetDateTime.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); OffsetDateTime test = OffsetDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); } }
Example 14
Source File: TCKLocalTime.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; int min = 0; int sec = 0; for (int i = 0; i < 3700; i++) { t = t.minusSeconds(1); sec--; if (sec == -1) { min--; sec = 59; if (min == -1) { hour--; min = 59; if (hour == -1) { hour = 23; } } } assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); } }
Example 15
Source File: TCKLocalTime.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; int min = 0; int sec = 0; for (int i = 0; i < 3700; i++) { t = t.minusSeconds(1); sec--; if (sec == -1) { min--; sec = 59; if (min == -1) { hour--; min = 59; if (hour == -1) { hour = 23; } } } assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); } }
Example 16
Source File: TCKLocalTime.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="minusSeconds_fromZero") public void test_minusSeconds_fromZero(int seconds, int hour, int min, int sec) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.minusSeconds(seconds); assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); }
Example 17
Source File: TCKLocalTime.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; int min = 0; int sec = 0; for (int i = 0; i < 3700; i++) { t = t.minusSeconds(1); sec--; if (sec == -1) { min--; sec = 59; if (min == -1) { hour--; min = 59; if (hour == -1) { hour = 23; } } } assertEquals(t.getHour(), hour); assertEquals(t.getMinute(), min); assertEquals(t.getSecond(), sec); } }
Example 18
Source File: TCKOffsetDateTime.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); OffsetDateTime test = OffsetDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); assertEquals(test.getOffset(), ZoneOffset.UTC); } }
Example 19
Source File: TCKLocalDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); LocalDateTime test = LocalDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); } }
Example 20
Source File: TCKLocalDateTime.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); LocalDateTime test = LocalDateTime.now(clock); assertEquals(test.getYear(), 1969); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); expected = expected.minusSeconds(1); assertEquals(test.toLocalTime(), expected); } }