Java Code Examples for java.time.Duration#getUnits()
The following examples show how to use
java.time.Duration#getUnits() .
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: DurationParser.java From spring-vault with Apache License 2.0 | 6 votes |
/** * Format a {@link Duration} into the Go format representation. * @param duration the duration object to format. * @return the duration formatted in Go's duration format. */ public static String formatDuration(Duration duration) { StringBuilder builder = new StringBuilder(); for (TemporalUnit unit : duration.getUnits()) { if (unit == ChronoUnit.MINUTES) { builder.append(duration.get(unit)).append('m'); } if (unit == ChronoUnit.HOURS) { builder.append(duration.get(unit)).append('h'); } if (unit == ChronoUnit.SECONDS) { builder.append(duration.get(unit)).append('s'); } if (unit == ChronoUnit.MILLIS) { builder.append(duration.get(unit)).append("ms"); } if (unit == ChronoUnit.NANOS) { builder.append(duration.get(unit)).append("ns"); } } return builder.toString(); }
Example 2
Source File: TCKDuration.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 3
Source File: TCKDuration.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 4
Source File: TCKDuration.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 5
Source File: TCKDuration.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 6
Source File: TCKDuration.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 7
Source File: TCKDuration.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 8
Source File: TCKDuration.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 9
Source File: TCKDuration.java From hottub with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 10
Source File: TCKDuration.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 11
Source File: TCKDuration.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 12
Source File: TCKDuration.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 13
Source File: TCKDuration.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 14
Source File: TCKDuration.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test(groups="{tck}") public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals(units.size(), 2, "Period.getUnits length"); assertTrue(units.contains(ChronoUnit.SECONDS), "Period.getUnits contains ChronoUnit.SECONDS"); assertTrue(units.contains(ChronoUnit.NANOS), "contains ChronoUnit.NANOS"); }
Example 15
Source File: TCKDuration.java From j2objc with Apache License 2.0 | 5 votes |
@Test() public void test_duration_getUnits() { Duration duration = Duration.ofSeconds(5000, 1000); List<TemporalUnit> units = duration.getUnits(); assertEquals("Period.getUnits length", units.size(), 2); assertTrue("Period.getUnits contains ChronoUnit.SECONDS", units.contains(ChronoUnit.SECONDS)); assertTrue("contains ChronoUnit.NANOS", units.contains(ChronoUnit.NANOS)); }