Java Code Examples for java.time.temporal.ChronoUnit#MINUTES
The following examples show how to use
java.time.temporal.ChronoUnit#MINUTES .
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: ExpiryUtils.java From ehcache3 with Apache License 2.0 | 6 votes |
public static TemporalUnit jucTimeUnitToTemporalUnit(TimeUnit timeUnit) { switch (timeUnit) { case NANOSECONDS: return ChronoUnit.NANOS; case MICROSECONDS: return ChronoUnit.MICROS; case MILLISECONDS: return ChronoUnit.MILLIS; case SECONDS: return ChronoUnit.SECONDS; case MINUTES: return ChronoUnit.MINUTES; case HOURS: return ChronoUnit.HOURS; case DAYS: return ChronoUnit.DAYS; default: throw new AssertionError("Unkown TimeUnit: " + timeUnit); } }
Example 2
Source File: Temporals.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
public static ChronoUnit chronoUnit(TimeUnit unit) { switch (unit) { case NANOSECONDS: return ChronoUnit.NANOS; case MICROSECONDS: return ChronoUnit.MICROS; case MILLISECONDS: return ChronoUnit.MILLIS; case SECONDS: return ChronoUnit.SECONDS; case MINUTES: return ChronoUnit.MINUTES; case HOURS: return ChronoUnit.HOURS; case DAYS: return ChronoUnit.DAYS; default: throw new IllegalArgumentException("Cannot convert timeunit"); } }
Example 3
Source File: FuzzyValues.java From icure-backend with GNU General Public License v2.0 | 6 votes |
public static long getFuzzyDateTime(LocalDateTime dateTime, TemporalUnit precision) { int seconds = dateTime.getSecond(); /*if (seconds == 0 && precision==ChronoUnit.SECONDS) { seconds = 60; dateTime = dateTime.minusMinutes(1); }*/ int minutes = dateTime.getMinute(); if (minutes == 0 && precision == ChronoUnit.MINUTES) { minutes = 60; dateTime = dateTime.minusHours(1); } int hours = dateTime.getHour(); if (hours == 0 && precision == ChronoUnit.HOURS) { hours = 24; dateTime = dateTime.minusDays(1); } return getFuzzyDate(dateTime, precision) * 1000000l + (precision == ChronoUnit.DAYS ? 0 : ( hours * 10000l + (precision == ChronoUnit.HOURS ? 0 : ( minutes * 100l + (precision == ChronoUnit.MINUTES ? 0 : seconds))))); }
Example 4
Source File: XmlModel.java From ehcache3 with Apache License 2.0 | 6 votes |
public static TemporalUnit convertToJavaTimeUnit(org.ehcache.xml.model.TimeUnit unit) { switch (unit) { case NANOS: return ChronoUnit.NANOS; case MICROS: return ChronoUnit.MICROS; case MILLIS: return ChronoUnit.MILLIS; case SECONDS: return ChronoUnit.SECONDS; case MINUTES: return ChronoUnit.MINUTES; case HOURS: return ChronoUnit.HOURS; case DAYS: return ChronoUnit.DAYS; default: throw new IllegalArgumentException("Unknown time unit: " + unit); } }
Example 5
Source File: Temporals.java From grakn with GNU Affero General Public License v3.0 | 6 votes |
public static ChronoUnit chronoUnit(TimeUnit unit) { switch (unit) { case NANOSECONDS: return ChronoUnit.NANOS; case MICROSECONDS: return ChronoUnit.MICROS; case MILLISECONDS: return ChronoUnit.MILLIS; case SECONDS: return ChronoUnit.SECONDS; case MINUTES: return ChronoUnit.MINUTES; case HOURS: return ChronoUnit.HOURS; case DAYS: return ChronoUnit.DAYS; default: throw new IllegalArgumentException("Cannot convert timeunit"); } }
Example 6
Source File: DateMatchers.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private static ChronoUnit convertUnit(final TimeUnit unit) { switch (unit) { case DAYS: return ChronoUnit.DAYS; case HOURS: return ChronoUnit.HOURS; case MICROSECONDS: return ChronoUnit.MICROS; case MILLISECONDS: return ChronoUnit.MILLIS; case MINUTES: return ChronoUnit.MINUTES; case NANOSECONDS: return ChronoUnit.NANOS; case SECONDS: return ChronoUnit.SECONDS; default: throw new IllegalArgumentException("Unknown TimeUnit '" + unit + "'"); } }
Example 7
Source File: XmlModel.java From ehcache3 with Apache License 2.0 | 6 votes |
public static TemporalUnit convertToJavaTemporalUnit(org.ehcache.xml.model.TimeUnit unit) { switch (unit) { case NANOS: return ChronoUnit.NANOS; case MICROS: return ChronoUnit.MICROS; case MILLIS: return ChronoUnit.MILLIS; case SECONDS: return ChronoUnit.SECONDS; case MINUTES: return ChronoUnit.MINUTES; case HOURS: return ChronoUnit.HOURS; case DAYS: return ChronoUnit.DAYS; default: throw new IllegalArgumentException("Unknown time unit: " + unit); } }
Example 8
Source File: Cache.java From chart-fx with Apache License 2.0 | 6 votes |
protected static ChronoUnit convertToChronoUnit(final TimeUnit timeUnit) { switch (timeUnit) { case NANOSECONDS: return ChronoUnit.NANOS; case MICROSECONDS: return ChronoUnit.MICROS; case SECONDS: return ChronoUnit.SECONDS; case MINUTES: return ChronoUnit.MINUTES; case HOURS: return ChronoUnit.HOURS; case DAYS: return ChronoUnit.DAYS; case MILLISECONDS: default: return ChronoUnit.MILLIS; } }
Example 9
Source File: TimeUtils.java From flink with Apache License 2.0 | 5 votes |
private static ChronoUnit toChronoUnit(java.util.concurrent.TimeUnit timeUnit) { switch(timeUnit) { case NANOSECONDS: return ChronoUnit.NANOS; case MICROSECONDS: return ChronoUnit.MICROS; case MILLISECONDS: return ChronoUnit.MILLIS; case SECONDS: return ChronoUnit.SECONDS; case MINUTES: return ChronoUnit.MINUTES; case HOURS: return ChronoUnit.HOURS; case DAYS: return ChronoUnit.DAYS; default: throw new IllegalArgumentException(String.format("Unsupported time unit %s.", timeUnit)); } }
Example 10
Source File: LootTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Schedule( period = 5, unit = ChronoUnit.MINUTES, asynchronous = true ) public void submitLootTask() { submitLoot(); }
Example 11
Source File: FindResult.java From find with MIT License | 5 votes |
@SuppressWarnings("TypeMayBeWeakened") private ZonedDateTime parseRelativeTime(final ZonedDateTime timeNow, final int timeAmount, final String timeUnit) { TemporalUnit temporalUnit = ChronoUnit.SECONDS; switch (timeUnit) { case "minute": case "minutes": temporalUnit = ChronoUnit.MINUTES; break; case "hour": case "hours": temporalUnit = ChronoUnit.HOURS; break; case "day": case "days": temporalUnit = ChronoUnit.DAYS; break; case "month": case "months": temporalUnit = ChronoUnit.MONTHS; break; case "year": case "years": temporalUnit = ChronoUnit.YEARS; break; } return timeNow.plus(timeAmount, temporalUnit); }
Example 12
Source File: TestHelpers.java From anomaly-detection with Apache License 2.0 | 5 votes |
public static IntervalSchedule randomIntervalSchedule() { return new IntervalSchedule( Instant.now().truncatedTo(ChronoUnit.SECONDS), ESRestTestCase.randomIntBetween(1, 1000), ChronoUnit.MINUTES ); }
Example 13
Source File: AllMetricsBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Retry(maxRetries = 5) @Bulkhead(3) @Timeout(value = 1, unit = ChronoUnit.MINUTES) @CircuitBreaker(failureRatio = 1.0, requestVolumeThreshold = 20) @Fallback(fallbackMethod = "doFallback") @Asynchronous public Future<Void> doWork() { return CompletableFuture.completedFuture(null); }
Example 14
Source File: AnomalyDetectorJobRunnerTests.java From anomaly-detection with Apache License 2.0 | 4 votes |
private void setUpJobParameter() { when(jobParameter.getName()).thenReturn(randomAlphaOfLength(10)); IntervalSchedule schedule = new IntervalSchedule(Instant.now(), 1, ChronoUnit.MINUTES); when(jobParameter.getSchedule()).thenReturn(schedule); when(jobParameter.getWindowDelay()).thenReturn(new IntervalTimeConfiguration(10, ChronoUnit.SECONDS)); }
Example 15
Source File: ForemanTimer.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
ForemanTimer(BlastFurnacePlugin plugin, ItemManager itemManager) { super(10, ChronoUnit.MINUTES, itemManager.getImage(ItemID.COAL_BAG), plugin); setTooltip(TOOLTIP_TEXT); }
Example 16
Source File: TimeUtil.java From L2jOrg with GNU General Public License v3.0 | 4 votes |
/** * Parses patterns like: * <ul> * <li>1min or 10mins</li> * <li>1day or 10days</li> * <li>1week or 4weeks</li> * <li>1month or 12months</li> * <li>1year or 5years</li> * </ul> * @param datePattern * @return {@link Duration} object converted by the date pattern specified. * @throws IllegalStateException when malformed pattern specified. */ public static Duration parseDuration(String datePattern) { final int index = findIndexOfNonDigit(datePattern); if (index == -1) { throw new IllegalStateException("Incorrect time format given: " + datePattern); } try { final int val = Integer.parseInt(datePattern.substring(0, index)); final String type = datePattern.substring(index); final ChronoUnit unit; switch (type.toLowerCase()) { case "sec": case "secs": { unit = ChronoUnit.SECONDS; break; } case "min": case "mins": { unit = ChronoUnit.MINUTES; break; } case "hour": case "hours": { unit = ChronoUnit.HOURS; break; } case "day": case "days": { unit = ChronoUnit.DAYS; break; } case "week": case "weeks": { unit = ChronoUnit.WEEKS; break; } case "month": case "months": { unit = ChronoUnit.MONTHS; break; } case "year": case "years": { unit = ChronoUnit.YEARS; break; } default: { unit = ChronoUnit.valueOf(type); if (unit == null) { throw new IllegalStateException("Incorrect format: " + type + " !!"); } } } return Duration.of(val, unit); } catch (Exception e) { throw new IllegalStateException("Incorrect time format given: " + datePattern + " val: " + datePattern.substring(0, index)); } }
Example 17
Source File: TimePeriodSpec.java From java-timeseries with MIT License | 4 votes |
@Test public void whenFrequencyPerComputedResultCorrect() { TimePeriod nanos = new TimePeriod(ChronoUnit.MINUTES, 4); assertThat(nanos.frequencyPer(TimePeriod.halfHour()), is(equalTo(7.5))); }
Example 18
Source File: AgilityArenaTimer.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
AgilityArenaTimer(Plugin plugin, BufferedImage image) { super(1, ChronoUnit.MINUTES, image, plugin); setTooltip("Time left until location changes"); }
Example 19
Source File: AgilityArenaTimer.java From plugins with GNU General Public License v3.0 | 4 votes |
AgilityArenaTimer(Plugin plugin, BufferedImage image) { super(1, ChronoUnit.MINUTES, image, plugin); setTooltip("Time left until location changes"); }
Example 20
Source File: TimeIntervalTest.java From influxdb-client-java with MIT License | 3 votes |
@Test void minutes() { TimeInterval interval = new TimeInterval(5L, ChronoUnit.MINUTES); Assertions.assertThat(interval.toString()).isEqualTo("5m"); }