- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.time.ZonedDateTime.minusSeconds()
方法的一些代码示例,展示了ZonedDateTime.minusSeconds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.minusSeconds()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:minusSeconds
[英]Returns a copy of this ZonedDateTime with the specified period in seconds subtracted.
This operates on the instant time-line, such that subtracting one second will always be a duration of one second earlier. This may cause the local date-time to change by an amount other than one second. Note that this is a different approach to that used by days, months and years.
This instance is immutable and unaffected by this method call.
[中]返回此ZoneDateTime的副本,并减去指定的时间段(以秒为单位)。
这是在即时时间线上进行的,因此减去一秒的持续时间将始终提前一秒。这可能会导致本地日期时间的变化量超过1秒。请注意,这与日、月和年使用的方法不同。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: org.elasticsearch/elasticsearch
public ZonedDateTime minusSeconds(long amount) {
return dt.minusSeconds(amount);
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns a {@link java.time.ZonedDateTime} that is {@code seconds} seconds before this date/time.
*
* @param self a ZonedDateTime
* @param seconds the number of seconds to subtract
* @return a ZonedDateTime
* @since 2.5.0
*/
public static ZonedDateTime minus(final ZonedDateTime self, long seconds) {
return self.minusSeconds(seconds);
}
代码示例来源:origin: UniversaBlockchain/universa
@Override
public void decreaseExpiresAt(int decreaseSeconds) {
expiresAt = expiresAt.minusSeconds(decreaseSeconds);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
public ZonedDateTime minusSeconds(long amount) {
return dt.minusSeconds(amount);
}
代码示例来源:origin: apache/servicemix-bundles
public ZonedDateTime minusSeconds(long amount) {
return dt.minusSeconds(amount);
}
代码示例来源:origin: stackoverflow.com
ZonedDateTime java8DateTime = ZonedDateTime.now(); // uses ZoneId.systemDefault()
ZonedDateTime java8DateTimeInPast = java8DateTime.minusSeconds(60);
doSomething(java8DateTimeInPast.toInstant());
代码示例来源:origin: org.apereo.cas/cas-server-support-throttle-core
/**
* Gets failure in range cut off date.
*
* @return the failure in range cut off date
*/
protected Date getFailureInRangeCutOffDate() {
val cutoff = ZonedDateTime.now(ZoneOffset.UTC).minusSeconds(getFailureRangeInSeconds());
return DateTimeUtils.timestampOf(cutoff);
}
代码示例来源:origin: logzio/sawmill
private static Map<String, Object> generateApacheLog() {
Map<String,Object> map = new HashMap<>();
String datetime = ZonedDateTime.now().minusSeconds(random.nextInt(3000)).format(DateTimeFormatter.ofPattern("dd/MMM/yyyy:HH:mm:ss Z"));
String ip = faker.internet().ipV4Address();
String method = getRandomItemFromList(methods);
String response = getRandomItemFromList(responses);
String resource = "/" + String.join("/", resources.subList(random.nextInt(5), 4 + random.nextInt(5)));
String ua = getRandomItemFromList(userAgents);
String bytes = String.valueOf(random.nextInt(5000));
String referrer = faker.internet().url();
map.put("message",
String.format("%s - - [%s] \"%s %s HTTP/1.1\" %s %s \"%s\" \"%s\"",ip, datetime, method, resource, response, bytes, referrer, ua));
return map;
}
代码示例来源:origin: com.conveyal/r5
void addItinerary(Integer accessIdx, Integer egressIdx,
List<TransitJourneyID> transitJourneyIDs, ZoneId timeZone) {
Itinerary itinerary = new Itinerary();
itinerary.transfers = transitJourneyIDs.size() - 1;
itinerary.walkTime = access.get(accessIdx).duration+egress.get(egressIdx).duration;
itinerary.distance = access.get(accessIdx).distance+egress.get(egressIdx).distance;
ZonedDateTime transitStart = transit.get(0).segmentPatterns.get(transitJourneyIDs.get(0).pattern).fromDepartureTime.get(transitJourneyIDs.get(0).time);
itinerary.startTime = transitStart.minusSeconds(access.get(accessIdx).duration);
int lastTransit = transitJourneyIDs.size()-1;
ZonedDateTime transitStop = transit.get(lastTransit).segmentPatterns.get(transitJourneyIDs.get(lastTransit).pattern).toArrivalTime.get(transitJourneyIDs.get(lastTransit).time);
itinerary.endTime = transitStop.plusSeconds(egress.get(egressIdx).duration);
itinerary.duration = (int) Duration.between(itinerary.startTime,itinerary.endTime).getSeconds();
itinerary.transitTime = 0;
int transitJourneyIDIdx=0;
for(TransitJourneyID transitJourneyID: transitJourneyIDs) {
itinerary.transitTime += transit.get(transitJourneyIDIdx).getTransitTime(transitJourneyID);
transitJourneyIDIdx++;
}
itinerary.waitingTime=itinerary.duration-(itinerary.transitTime+itinerary.walkTime);
PointToPointConnection pointToPointConnection = new PointToPointConnection(accessIdx, egressIdx, transitJourneyIDs);
itinerary.addConnection(pointToPointConnection);
this.itinerary.add(itinerary);
}
代码示例来源:origin: conveyal/r5
void addItinerary(Integer accessIdx, Integer egressIdx,
List<TransitJourneyID> transitJourneyIDs, ZoneId timeZone) {
Itinerary itinerary = new Itinerary();
itinerary.transfers = transitJourneyIDs.size() - 1;
itinerary.walkTime = access.get(accessIdx).duration+egress.get(egressIdx).duration;
itinerary.distance = access.get(accessIdx).distance+egress.get(egressIdx).distance;
ZonedDateTime transitStart = transit.get(0).segmentPatterns.get(transitJourneyIDs.get(0).pattern).fromDepartureTime.get(transitJourneyIDs.get(0).time);
itinerary.startTime = transitStart.minusSeconds(access.get(accessIdx).duration);
int lastTransit = transitJourneyIDs.size()-1;
ZonedDateTime transitStop = transit.get(lastTransit).segmentPatterns.get(transitJourneyIDs.get(lastTransit).pattern).toArrivalTime.get(transitJourneyIDs.get(lastTransit).time);
itinerary.endTime = transitStop.plusSeconds(egress.get(egressIdx).duration);
itinerary.duration = (int) Duration.between(itinerary.startTime,itinerary.endTime).getSeconds();
itinerary.transitTime = 0;
int transitJourneyIDIdx=0;
for(TransitJourneyID transitJourneyID: transitJourneyIDs) {
itinerary.transitTime += transit.get(transitJourneyIDIdx).getTransitTime(transitJourneyID);
transitJourneyIDIdx++;
}
itinerary.waitingTime=itinerary.duration-(itinerary.transitTime+itinerary.walkTime);
PointToPointConnection pointToPointConnection = new PointToPointConnection(accessIdx, egressIdx, transitJourneyIDs);
itinerary.addConnection(pointToPointConnection);
this.itinerary.add(itinerary);
}
代码示例来源:origin: org.apereo.cas/cas-server-support-saml
@Override
protected void renderMergedOutputModel(final Map<String, Object> model,
final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
try {
response.setCharacterEncoding(this.encoding);
val service = this.samlArgumentExtractor.extractService(request);
val serviceId = getServiceIdFromRequest(service);
LOGGER.debug("Using [{}] as the recipient of the SAML response for [{}]", serviceId, service);
val samlResponse = this.samlObjectBuilder.newResponse(
this.samlObjectBuilder.generateSecureRandomId(),
ZonedDateTime.now(ZoneOffset.UTC).minusSeconds(this.skewAllowance), serviceId, service);
LOGGER.debug("Created SAML response for service [{}]", serviceId);
prepareResponse(samlResponse, model);
LOGGER.debug("Starting to encode SAML response for service [{}]", serviceId);
this.samlObjectBuilder.encodeSamlResponse(response, request, samlResponse);
} catch (final Exception e) {
LOGGER.error("Error generating SAML response for service", e);
throw e;
}
}
代码示例来源:origin: com.cronutils/cron-utils
/**
* Provide nearest date for last execution.
*
* @param date - ZonedDateTime instance. If null, a NullPointerException will be raised.
* @return Optional ZonedDateTime instance, never null. Last execution time or empty.
*/
public Optional<ZonedDateTime> lastExecution(final ZonedDateTime date) {
Preconditions.checkNotNull(date);
try {
ZonedDateTime previousMatch = previousClosestMatch(date);
if (previousMatch.equals(date)) {
previousMatch = previousClosestMatch(date.minusSeconds(1));
}
return Optional.of(previousMatch);
} catch (final NoSuchValueException e) {
return Optional.empty();
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-x509-core
/**
* {@inheritDoc}
* The CRL next update time is compared against the current time with the threshold
* applied and rejected if and only if the next update time is in the past.
*
* @param crl CRL instance to evaluate.
* @throws ExpiredCRLException On expired CRL data. Check the exception type for exact details
*/
@Override
public void apply(final X509CRL crl) throws ExpiredCRLException {
val cutoff = ZonedDateTime.now(ZoneOffset.UTC);
if (CertUtils.isExpired(crl, cutoff)) {
if (CertUtils.isExpired(crl, cutoff.minusSeconds(this.threshold))) {
throw new ExpiredCRLException(crl.toString(), cutoff, this.threshold);
}
LOGGER.info(String.format("CRL expired on %s but is within threshold period, %s seconds.",
crl.getNextUpdate(), this.threshold));
}
}
}
代码示例来源:origin: SonarSource/sonarlint-intellij
@Test
public void testSet() {
SonarLintProjectState state = new SonarLintProjectState();
state.setLastEventPolling(ZonedDateTime.now());
assertThat(state.getLastEventPolling()).isBeforeOrEqualTo(ZonedDateTime.now());
assertThat(state.getLastEventPolling()).isAfter(ZonedDateTime.now().minusSeconds(3));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void queryForCreatedAtIsGreaterThan() {
createdAtTest((m, date) -> m.isGreaterThan(date.minusSeconds(1)));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void queryForCreatedAtIsGreaterThanOrEqualTo() {
createdAtTest((m, date) -> m.isGreaterThanOrEqualTo(date.minusSeconds(1)));
}
代码示例来源:origin: com.cronutils/cron-utils
private static ExecutionTimeResult getPreviousPotentialValue(
final ZonedDateTime date,
final TimeNode node,
final TemporalField field) throws NoSuchValueException {
Set<Integer> values = new HashSet<>(node.values);
TemporalUnit unit = field.getBaseUnit();
long maximum = field.range().getMaximum();
long minimum = field.range().getMinimum();
long range = maximum - minimum;
ZonedDateTime newDate = date;
for (long i = 0; i < 2 * range; i++) {
newDate = newDate.minus(1, unit);
if (values.contains(newDate.get(field))) {
newDate = newDate
.truncatedTo(unit)
.plus(1, unit)
.minusSeconds(1);
return new ExecutionTimeResult(newDate, false);
}
}
throw new NoSuchValueException();
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
public Health getHealth() {
HealthCheckConfiguration healthCheckConfiguration = configuration.getHealthCheckConfiguration();
ZonedDateTime currentTime = currentTimeSupplier.get();
ZonedDateTime xSecondsAgo = currentTime.minusSeconds(healthCheckConfiguration.getTimeRangeInSeconds());
OperationFilter filter = new OperationFilter.Builder().mtaId(healthCheckConfiguration.getMtaId())
.spaceId(healthCheckConfiguration.getSpaceId())
.user(healthCheckConfiguration.getUserName())
.endedAfter(Date.from(xSecondsAgo.toInstant()))
.inFinalState()
.orderByEndTime()
.descending()
.build();
List<Operation> healthCheckOperations = operationDao.find(filter);
return Health.fromOperations(healthCheckOperations);
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void getCompletedAt() throws Exception {
final ZonedDateTime completedAt = SphereTestUtils.now().minusSeconds(5555);
testOrderAspect(builder -> builder.completedAt(completedAt),
order -> assertThat(order.getCompletedAt()).isEqualTo(completedAt));
}
代码示例来源:origin: apache/incubator-rya
@Test
public void testSeconds() throws DatatypeConfigurationException, ValueExprEvaluationException {
DatatypeFactory dtf = DatatypeFactory.newInstance();
ZonedDateTime zTime = testThisTimeDate;
String time = zTime.format(DateTimeFormatter.ISO_INSTANT);
ZonedDateTime zTime1 = zTime.minusSeconds(1);
String time1 = zTime1.format(DateTimeFormatter.ISO_INSTANT);
Literal now = VF.createLiteral(dtf.newXMLGregorianCalendar(time));
Literal nowMinusOne = VF.createLiteral(dtf.newXMLGregorianCalendar(time1));
DateTimeWithinPeriod func = new DateTimeWithinPeriod();
assertEquals(TRUE, func.evaluate(VF, now, now, VF.createLiteral(1), OWLTime.SECONDS_URI));
assertEquals(FALSE, func.evaluate(VF, now, nowMinusOne,VF.createLiteral(1), OWLTime.SECONDS_URI));
assertEquals(TRUE, func.evaluate(VF, now, nowMinusOne,VF.createLiteral(2), OWLTime.SECONDS_URI));
}
我尝试理解[c代码 -> 汇编]代码 void node::Check( data & _data1, vector& _data2) { -> push ebp -> mov ebp,esp ->
我需要在当前表单(代码)的上下文中运行文本文件中的代码。其中一项要求是让代码创建新控件并将其添加到当前窗体。 例如,在Form1.cs中: using System.Windows.Forms; ..
我有此 C++ 代码并将其转换为 C# (.net Framework 4) 代码。有没有人给我一些关于 malloc、free 和 sprintf 方法的提示? int monate = ee; d
我的网络服务器代码有问题 #include #include #include #include #include #include #include int
给定以下 html 代码,将列表中的第三个元素(即“美丽”一词)以斜体显示的 CSS 代码是什么?当然,我可以给这个元素一个 id 或一个 class,但 html 代码必须保持不变。谢谢
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我试图制作一个宏来避免重复代码和注释。 我试过这个: #define GrowOnPage(any Page, any Component) Component.Width := Page.Surfa
我正在尝试将我的旧 C++ 代码“翻译”成头条新闻所暗示的 C# 代码。问题是我是 C# 中的新手,并不是所有的东西都像 C++ 中那样。在 C++ 中这些解决方案运行良好,但在 C# 中只是不能。我
在 Windows 10 上工作,R 语言的格式化程序似乎没有在 Visual Studio Code 中完成它的工作。我试过R support for Visual Studio Code和 R-T
我正在处理一些报告(计数),我必须获取不同参数的计数。非常简单但乏味。 一个参数的示例查询: qCountsEmployee = ( "select count(*) from %s wher
最近几天我尝试从 d00m 调试网络错误。我开始用尽想法/线索,我希望其他 SO 用户拥有可能有用的宝贵经验。我希望能够提供所有相关信息,但我个人无法控制服务器环境。 整个事情始于用户注意到我们应用程
我有一个 app.js 文件,其中包含如下 dojo amd 模式代码: require(["dojo/dom", ..], function(dom){ dom.byId('someId').i
我对“-gencode”语句中的“code=sm_X”选项有点困惑。 一个例子:NVCC 编译器选项有什么作用 -gencode arch=compute_13,code=sm_13 嵌入库中? 只有
我为我的表格使用 X-editable 框架。 但是我有一些问题。 $(document).ready(function() { $('.access').editable({
我一直在通过本教程学习 flask/python http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-wo
我想将 Vim 和 EMACS 用于 CNC、G 代码和 M 代码。 Vim 或 EMACS 是否有任何语法或模式来处理这种类型的代码? 最佳答案 一些快速搜索使我找到了 this vim 和 thi
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve this
这个问题在这里已经有了答案: Enabling markdown highlighting in Vim (5 个回答) 6年前关闭。 当我在 Vim 中编辑包含 Markdown 代码的 READM
我正在 Swift3 iOS 中开发视频应用程序。基本上我必须将视频 Assets 和音频与淡入淡出效果合并为一个并将其保存到 iPhone 画廊。为此,我使用以下方法: private func d
pipeline { agent any stages { stage('Build') { steps { e
我是一名优秀的程序员,十分优秀!