本文整理了Java中org.apache.wicket.util.time.Time
类的一些代码示例,展示了Time
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time
类的具体详情如下:
包路径:org.apache.wicket.util.time.Time
类名称:Time
[英]An immutable Time
class that represents a specific point in time. The underlying representation is a long
value which holds a number of milliseconds since January 1, 1970, 0:00 GMT. To represent a duration of time, such as "6 seconds", use the Duration
class. To represent a time period with a start and end time, use the TimeFrame
class. To represent a time of day, use the TimeOfDay
class.
[中]表示特定时间点的不可变Time
类。基本表示法是一个long
值,它保存自1970年1月1日格林威治标准时间0:00以来的毫秒数。要表示时间的持续时间,例如“6秒”,请使用Duration
类。要用开始和结束时间表示时间段,请使用TimeFrame
类。要表示一天中的某个时间,请使用TimeOfDay
类。
代码示例来源:origin: org.wicketstuff/wicket-poi
@Override
public Time lastModifiedTime()
{
return Time.now();
}
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* Retrieves the next occurrence of this <code>TimeOfDay</code> on the given
* <code>Calendar</code>.
*
* @param calendar
* the <code>Calendar</code> to use
* @return the next occurrence of this <code>TimeOfDay</code> on the given <code>Calendar</code>
*/
public Time next(final Calendar calendar)
{
// Get this time of day today
final Time timeToday = Time.valueOf(calendar, this);
// If it has already passed
if (timeToday.before(Time.now()))
{
// Return the time tomorrow
return Time.valueOf(calendar, this).add(Duration.ONE_DAY);
}
else
{
// Time hasn't happened yet today
return timeToday;
}
}
代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service
/**
* Adds the given <code>Duration</code> to this <code>Time</code> object, moving the time into
* the future.
*
* @param duration
* the <code>Duration</code> to add
* @return this <code>Time</code> + <code>Duration</code>
*/
public Time add(final Duration duration)
{
return milliseconds(getMilliseconds() + duration.getMilliseconds());
}
代码示例来源: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.ops4j.pax.wicket/pax-wicket-service
/**
* Determines if this <code>TimeFrame</code> contains a given point in time.
*
* @param time
* the <code>Time</code> to check
* @return <code>true</code> if this <code>TimeFrame</code> contains the given time
*/
public boolean contains(final Time time)
{
return (start.equals(time) || start.before(time)) && end.after(time);
}
代码示例来源:origin: org.wicketstuff/wicketstuff-push-timer
boolean isTimedOut()
{
return Time.now().subtract(lastPolledAt).greaterThan(_maxTimeLag);
}
}
代码示例来源:origin: apache/wicket
if (duration.compareTo(MAX_CACHE_DURATION) > 0)
Time now = Time.now();
setDateHeader("Expires", now.add(duration));
addHeader("Cache-Control", "max-age=" + Math.round(duration.seconds()));
代码示例来源:origin: org.onehippo.cms7/hippo-cms-console-frontend
@Override
protected InputStream getContent() {
try {
tempFile = File.createTempFile("export-" + Time.now().toString() + "-", ".xml");
FileOutputStream fos = new FileOutputStream(tempFile);
try {
代码示例来源: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());
}
代码示例来源: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.ops4j.pax.wicket/pax-wicket-service
/**
* Retrieves a <code>Time</code> instance based on the given {@link TimeOfDay} object.
*
* @param timeOfDay
* the time of day in local time
* @return a <code>Time</code> value for the time of day today
*/
public static Time valueOf(final TimeOfDay timeOfDay)
{
return valueOf(localtime, timeOfDay);
}
代码示例来源:origin: org.apache.wicket/wicket-examples-jar
@Override
protected void onConfigure() {
super.onConfigure();
// Clean up comments for comments older than one hour
for (Comment comment : comments) {
Time createdAt = Time.valueOf(comment.getCreatedAt());
if (Duration.elapsed(createdAt).seconds() > 10) {
comments.remove(comment);
}
}
}
代码示例来源: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/wicket-util
/**
* Subtract time from this and returns the difference as a <code>Duration</code> object.
*
* @param that
* the time to subtract
* @return the <code>Duration</code> between this and that time
*/
public Duration subtract(final Time that)
{
return Duration.milliseconds(getMilliseconds() - that.getMilliseconds());
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Subtracts the given <code>Duration</code> from this <code>Time</code> object, moving the time
* into the past.
*
* @param duration
* the <code>Duration</code> to subtract
* @return this duration of time
*/
public Time subtract(final Duration duration)
{
return millis(getMilliseconds() - duration.getMilliseconds());
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* @see org.apache.wicket.Response#setLastModifiedTime(org.apache.wicket.util.time.Time)
*/
public void setLastModifiedTime(Time time)
{
if (httpServletResponse != null)
{
if (time != null && time.getMilliseconds() != -1)
{
httpServletResponse.setDateHeader("Last-Modified", time.getMilliseconds());
}
}
}
代码示例来源:origin: apache/wicket
/**
* Check to determine if the resource data needs to be written. This method checks the
* <code>If-Modified-Since</code> request header and compares it to lastModified property.
* In order for this method to work {@link #setLastModified(Time)} has to be called first.
*
* @param attributes
* request attributes
* @return <code>true</code> if the resource data does need to be written,
* <code>false</code> otherwise.
*/
public boolean dataNeedsToBeWritten(Attributes attributes)
{
WebRequest request = (WebRequest)attributes.getRequest();
Time ifModifiedSince = request.getIfModifiedSinceHeader();
if (cacheDuration != Duration.NONE && ifModifiedSince != null && lastModified != null)
{
// [Last-Modified] headers have a maximum precision of one second
// so we have to truncate the milliseconds part for a proper compare.
// that's stupid, since changes within one second will not be reliably
// detected by the client ... any hint or clarification to improve this
// situation will be appreciated...
Time roundedLastModified = Time.millis(lastModified.getMilliseconds() / 1000 * 1000);
return ifModifiedSince.before(roundedLastModified);
}
else
{
return true;
}
}
代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket
/**
* Gets debug info as a string for the given cookie.
*
* @param cookie
* the cookie to debug.
* @return a string that represents the internals of the cookie.
*/
private String cookieToDebugString(final Cookie cookie)
{
return "[Cookie " + " name = " + cookie.getName() + ", value = " + cookie.getValue() +
", domain = " + cookie.getDomain() + ", path = " + cookie.getPath() + ", maxAge = " +
Time.valueOf(cookie.getMaxAge()).toDateString() + "(" + cookie.getMaxAge() + ")" + "]";
}
代码示例来源:origin: de.alpharogroup/jaulp-wicket-base
/**
* Gets the elapsed duration since this application was initialized.
*
* @return the uptime
*/
public Duration getUptime()
{
final DateTime startup = getStartupDate();
if (null != startup)
{
return Duration.elapsed(Time.valueOf(startup.toDate()));
}
return Duration.NONE;
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Converts this <code>Time</code> value to a <code>String</code> using the given format.
*
* @param format
* the format to use
* @return this <code>Time</code> value as a formatted string
*/
public String toString(final String format)
{
return toString(null, format);
}
内容来源于网络,如有侵权,请联系作者删除!