@Override public DateTimeValue sub( DurationValue duration ) { return replacement( assertValidArithmetic( () -> value.minus( duration ) ) ); }
/** * Best effort calculation of this {@link GCModel}s start date based on the available information * * @return the most probable start date of this {@link GCModel} */ public ZonedDateTime getStartDate() { ZonedDateTime suggestedStartDate = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getLastModified()), ZoneId.systemDefault()); if (hasDateStamp()) { suggestedStartDate = getFirstDateStamp(); } else if (hasCorrectTimestamp()) { double runningTimeInSeconds = getRunningTime(); long runningTimeInMillis = (long) (runningTimeInSeconds * 1000d); suggestedStartDate = suggestedStartDate.minus(runningTimeInMillis, ChronoUnit.MILLIS); } return suggestedStartDate; }
@Test public void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); RenderingResponse responseMono = RenderingResponse.create("bar") .header(HttpHeaders.LAST_MODIFIED, DateTimeFormatter.RFC_1123_DATE_TIME.format(oneMinuteBeforeNow)) .build() .block(); MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com") .header(HttpHeaders.IF_MODIFIED_SINCE, DateTimeFormatter.RFC_1123_DATE_TIME.format(now)) .build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); responseMono.writeTo(exchange, DefaultServerResponseBuilderTests.EMPTY_CONTEXT); MockServerHttpResponse response = exchange.getResponse(); assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode()); StepVerifier.create(response.getBody()) .expectError(IllegalStateException.class) .verify(); }
public ZonedDateTime minus(TemporalAmount delta) { return dt.minus(delta); }
public ZonedDateTime minus(long amount, TemporalUnit unit) { return dt.minus(amount, unit); }
@Test public void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); EntityResponse<String> responseMono = EntityResponse.fromObject("bar") .lastModified(oneMinuteBeforeNow) .build() .block(); MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com") .header(HttpHeaders.IF_MODIFIED_SINCE, DateTimeFormatter.RFC_1123_DATE_TIME.format(now)) .build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); responseMono.writeTo(exchange, DefaultServerResponseBuilderTests.EMPTY_CONTEXT); MockServerHttpResponse response = exchange.getResponse(); assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode()); StepVerifier.create(response.getBody()) .expectError(IllegalStateException.class) .verify(); }
@Test public void notModifiedLastModified() { ZonedDateTime now = ZonedDateTime.now(); ZonedDateTime oneMinuteBeforeNow = now.minus(1, ChronoUnit.MINUTES); ServerResponse responseMono = ServerResponse.ok() .lastModified(oneMinuteBeforeNow) .syncBody("bar") .block(); MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com") .header(HttpHeaders.IF_MODIFIED_SINCE, DateTimeFormatter.RFC_1123_DATE_TIME.format(now)) .build(); MockServerWebExchange exchange = MockServerWebExchange.from(request); responseMono.writeTo(exchange, EMPTY_CONTEXT); MockServerHttpResponse response = exchange.getResponse(); assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode()); StepVerifier.create(response.getBody()) .expectError(IllegalStateException.class) .verify(); }
void removeOldFiles(ZonedDateTime now) { if (_retainDays>0) { // Establish expiration time, based on configured TimeZone long expired = now.minus(_retainDays, ChronoUnit.DAYS).toInstant().toEpochMilli(); File file= new File(_filename); File dir = new File(file.getParent()); String fn=file.getName(); int s=fn.toLowerCase(Locale.ENGLISH).indexOf(YYYY_MM_DD); if (s<0) return; String prefix=fn.substring(0,s); String suffix=fn.substring(s+YYYY_MM_DD.length()); String[] logList=dir.list(); for (int i=0;i<logList.length;i++) { fn = logList[i]; if(fn.startsWith(prefix)&&fn.indexOf(suffix,prefix.length())>=0) { File f = new File(dir,fn); if(f.lastModified() < expired) { f.delete(); } } } } }
final ZonedDateTime seek = base.minus( (windowDistanceInterval * (pastWindows - i)), windowDistanceIntervalUnits);
dateTime = dateTime.minus(1, ChronoField.MILLI_OF_SECOND.getBaseUnit());
@Override public final boolean hasNext() { if (excludes != null) { while (excludes.test(value) && inBounds(value)) { value = ascend ? value.plus(step) : value.minus(step); } } return inBounds(value); } @Override
/** * Constructor. * @param timePeriod the time period * @param endTime the end time of the tick period */ public BaseTick(Duration timePeriod, ZonedDateTime endTime) { checkTimeArguments(timePeriod, endTime); this.timePeriod = timePeriod; this.endTime = endTime; this.beginTime = endTime.minus(timePeriod); }
public long getTotalNumberOfExceptionsForLast( final Duration duration ) { return getEntriesAfter(ZonedDateTime.now().minus(duration)).size(); } }
@VisibleForTesting ZonedDateTime nextExecutionTime(ZonedDateTime lastExecutionTime, long jitterMillis) { requireNonNull(lastExecutionTime, "lastExecutionTime"); final ZonedDateTime next = executionTime.nextExecution(lastExecutionTime.minus(jitterMillis, ChronoUnit.MILLIS)); return next.plus(jitterMillis, ChronoUnit.MILLIS); }
@VisibleForTesting ZonedDateTime nextExecutionTime(ZonedDateTime lastExecutionTime, long jitterMillis) { requireNonNull(lastExecutionTime, "lastExecutionTime"); final ZonedDateTime next = executionTime.nextExecution(lastExecutionTime.minus(jitterMillis, ChronoUnit.MILLIS)); return next.plus(jitterMillis, ChronoUnit.MILLIS); }
@Override public boolean deleteDataOlderThan(final TemporalAmount amount) throws IOException { Objects.requireNonNull(amount); final long now = proxy.getTime(); final long limit = TimeUtils.getCurrentStart(ZonedDateTime.ofInstant(Instant.ofEpochMilli(now), TimeUtils.zone) .minus(amount).toInstant(), proxy.unit).toEpochMilli(); return deleteDataFrom(limit, true); }
@Override public DateTime minus( Duration duration ) { CheckArg.isNotNull(duration, "unit"); return new ModeShapeDateTime(this.instance.minus(duration)); }
@Override public DateTime minus( Duration duration ) { CheckArg.isNotNull(duration, "unit"); return new ModeShapeDateTime(this.instance.minus(duration)); }
@Override public DateTimeValue sub( DurationValue duration ) { return replacement( assertValidArithmetic( () -> value.minus( duration ) ) ); }
@Override public QueryExecutionResult execute(QueryExecution queryExecution, Connection connection) throws SQLException { QueryExecutionResult executionResult = super.execute(queryExecution, connection); // Queries in tests need to seemingly take non-zero duration (measured with seconds precision), even if Graphite precision is subtracted. ZonedDateTime newStart = ((ZonedDateTime) ReflectionTestUtils.getField(executionResult, "utcStart")) .minus(2, ChronoUnit.SECONDS); ReflectionTestUtils.setField(executionResult, "utcStart", newStart); return executionResult; } };