本文整理了Java中org.apache.wicket.util.time.Time.subtract()
方法的一些代码示例,展示了Time.subtract()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.subtract()
方法的具体详情如下:
包路径:org.apache.wicket.util.time.Time
类名称:Time
方法名:subtract
[英]Subtracts the given Duration
from this Time
object, moving the time into the past.
[中]从这个Time
对象中减去给定的Duration
,将时间移到过去。
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* Retrieves the <code>Duration</code> of this <code>TimeFrame</code>.
*
* @return the <code>Duration</code> of this <code>TimeFrame</code>
*/
public Duration getDuration()
{
return end.subtract(start);
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* Retrieves the <code>Duration</code> of this <code>TimeFrame</code>.
*
* @return the <code>Duration</code> of this <code>TimeFrame</code>
*/
public Duration getDuration()
{
return end.subtract(start);
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Retrieves the <code>Duration</code> of this <code>TimeFrame</code>.
*
* @return the <code>Duration</code> of this <code>TimeFrame</code>
*/
public Duration getDuration()
{
return end.subtract(start);
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* Retrieves the <code>Duration</code> from now to this <code>Time</code> value. If this
* <code>Time</code> value is in the past, then the <code>Duration</code> returned will be
* negative. Otherwise, it will be the number of milliseconds from now to this <code>Time</code>
* .
*
* @return the <code>Duration</code> from now to this <code>Time</code> value
*/
public Duration fromNow()
{
return subtract(now());
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Retrieves the <code>Duration</code> from now to this <code>Time</code> value. If this
* <code>Time</code> value is in the past, then the <code>Duration</code> returned will be
* negative. Otherwise, it will be the number of milliseconds from now to this <code>Time</code>
* .
*
* @return the <code>Duration</code> from now to this <code>Time</code> value
*/
public Duration fromNow()
{
return subtract(now());
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* Retrieves the <code>Duration</code> from now to this <code>Time</code> value. If this
* <code>Time</code> value is in the past, then the <code>Duration</code> returned will be
* negative. Otherwise, it will be the number of milliseconds from now to this <code>Time</code>.
*
* @return the <code>Duration</code> from now to this <code>Time</code> value
*/
public Duration fromNow()
{
return subtract(now());
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Benchmark the given command.
*
* @param code
* a <code>Runnable</code>
* @return the <code>Time</code> value it took to run the code
*/
public static Duration benchmark(final Runnable code)
{
// Get time before running code
final Time start = Time.now();
// Run code
code.run();
// Return the difference
return Time.now().subtract(start);
}
代码示例来源:origin: org.wicketstuff/wicketstuff-push-timer
boolean isTimedOut()
{
return Time.now().subtract(lastPolledAt).greaterThan(_maxTimeLag);
}
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* Benchmark the given command.
*
* @param code
* a <code>Runnable</code>
* @return the <code>Time</code> value it took to run the code
*/
public static Duration benchmark(final Runnable code)
{
// Get time before running code
final Time start = Time.now();
// Run code
code.run();
// Return the difference
return Time.now().subtract(start);
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* Calculates the amount of time that has elapsed since this <code>Time</code> value.
*
* @return the amount of time that has elapsed since this <code>Time</code> value
* @throws IllegalStateException
* thrown if this <code>Time</code> value is in the future
*/
public Duration elapsedSince()
{
final Time now = now();
if (this.greaterThan(now))
{
throw new IllegalStateException("This time is in the future");
}
return now.subtract(this);
}
代码示例来源:origin: org.wicketstuff/push-timer
public void run()
{
LOG.debug("Running timer push node cleanup task...");
final Time now = Time.now();
int count = 0;
for (final PushNodeState<?> state : _nodeStates.values())
if (now.subtract(state.lastPolledAt).greaterThan(_maxTimeLag))
{
onDisconnect(state.node);
count++;
}
LOG.debug("Cleaned up {} timer push nodes.", count);
}
};
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Calculates the amount of time that has elapsed since this <code>Time</code> value.
*
* @return the amount of time that has elapsed since this <code>Time</code> value
* @throws IllegalStateException
* thrown if this <code>Time</code> value is in the future
*/
public Duration elapsedSince()
{
final Time now = now();
if (this.greaterThan(now))
{
throw new IllegalStateException("This time is in the future");
}
return now.subtract(this);
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* Benchmark the given command.
*
* @param code
* a <code>Runnable</code>
* @return the <code>Time</code> value it took to run the code
*/
public static Duration benchmark(final Runnable code)
{
// Get time before running code
final Time start = Time.now();
// Run code
code.run();
// Return the difference
return Time.now().subtract(start);
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* Calculates the amount of time that has elapsed since this <code>Time</code> value.
*
* @return the amount of time that has elapsed since this <code>Time</code> value
* @throws IllegalStateException
* thrown if this <code>Time</code> value is in the future
*/
public Duration elapsedSince()
{
final Time now = now();
if (this.greaterThan(now))
{
throw new IllegalStateException("This time is in the future");
}
return now.subtract(this);
}
代码示例来源:origin: org.apache.wicket/wicket-core
@Override
protected synchronized boolean removeEldestEntry(java.util.Map.Entry<String, Object> eldest)
{
boolean removed = super.removeEldestEntry(eldest);
if (removed == false)
{
Value value = (Value)eldest.getValue();
if (value != null)
{
Duration elapsedTime = Time.now().subtract(value.creationTime);
if (lifetime.lessThanOrEqual(elapsedTime))
{
removedValue = value.response;
removed = true;
}
}
}
return removed;
}
代码示例来源:origin: apache/wicket
@Override
protected synchronized boolean removeEldestEntry(java.util.Map.Entry<String, Object> eldest)
{
boolean removed = super.removeEldestEntry(eldest);
if (removed == false)
{
Value value = (Value)eldest.getValue();
if (value != null)
{
Duration elapsedTime = Time.now().subtract(value.creationTime);
if (lifetime.lessThanOrEqual(elapsedTime))
{
removedValue = value.response;
removed = true;
}
}
}
return removed;
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* Benchmark the given command.
*
* @param code
* an <code>ICode</code>
* @param log
* optional logger to use with errors and exceptions
* @return the <code>Time</code> value it took to run the code
*/
public static Duration benchmark(final ICode code, final Logger log)
{
// Get time before running code
final Time start = Time.now();
// Run the code
code.run(log);
// Return the difference
return Time.now().subtract(start);
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Benchmark the given command.
*
* @param code
* an <code>ICode</code>
* @param log
* optional logger to use with errors and exceptions
* @return the <code>Time</code> value it took to run the code
*/
public static Duration benchmark(final ICode code, final Logger log)
{
// Get time before running code
final Time start = Time.now();
// Run the code
code.run(log);
// Return the difference
return Time.now().subtract(start);
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* Benchmark the given command.
*
* @param code
* an <code>ICode</code>
* @param log
* optional logger to use with errors and exceptions
* @return the <code>Time</code> value it took to run the code
*/
public static Duration benchmark(final ICode code, final Logger log)
{
// Get time before running code
final Time start = Time.now();
// Run the code
code.run(log);
// Return the difference
return Time.now().subtract(start);
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-plugins
/**
* @see org.apache.wicket.IRequestTarget#respond(org.apache.wicket.RequestCycle)
*/
public void respond(RequestCycle requestCycle) {
final Application app = Application.get();
// Determine encoding
final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding();
// Set content type based on markup type for page
final WebResponse response = (WebResponse) requestCycle.getResponse();
response.setCharacterEncoding(encoding);
response.setContentType("text/plain; charset=" + encoding);
// Make sure it is not cached by a client
response.setHeader("Expires", Time.now().subtract(Duration.minutes(1)).toDateString());
response.setHeader("Cache-Control", "no-cache, must-revalidate");
response.setHeader("Pragma", "no-cache");
response.setLastModifiedTime(Time.now());
// set filename
response.setAttachmentHeader(getFilename());
response.write(getContent());
}
内容来源于网络,如有侵权,请联系作者删除!