本文整理了Java中org.apache.wicket.util.time.Time.millis()
方法的一些代码示例,展示了Time.millis()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.millis()
方法的具体详情如下:
包路径:org.apache.wicket.util.time.Time
类名称:Time
方法名:millis
[英]Retrieves a Time
instance based on the given milliseconds.
[中]基于给定的毫秒检索Time
实例。
代码示例来源:origin: org.wicketstuff/wicketstuff-jwicket-core
@Override
public Time lastModifiedTime() {
return Time.millis(0L);
}
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Retrieves a <code>Time</code> instance based on the current time.
*
* @return the current <code>Time</code>
*/
public static Time now()
{
return millis(System.currentTimeMillis());
}
代码示例来源:origin: apache/wicket
@Override
public Time getDateHeader(String name)
{
try
{
long value = httpServletRequest.getDateHeader(name);
if (value == -1)
{
return null;
}
return Time.millis(value);
}
catch (IllegalArgumentException e)
{
// per spec thrown if the header contains a value that cannot be converted to a date
return null;
}
}
代码示例来源:origin: org.apache.wicket/wicket-core
@Override
public Time getDateHeader(String name)
{
try
{
long value = httpServletRequest.getDateHeader(name);
if (value == -1)
{
return null;
}
return Time.millis(value);
}
catch (IllegalArgumentException e)
{
// per spec thrown if the header contains a value that cannot be converted to a date
return null;
}
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* get last modification timestamp for file
*
* @param file
*
* @return timestamp
*/
public static Time getLastModified(File file)
{
// get file modification timestamp
long millis = file.lastModified();
// zero indicates the timestamp could not be retrieved or the file does not exist
if (millis == 0)
{
return null;
}
// last file modification timestamp
return Time.millis(millis);
}
代码示例来源:origin: org.apache.wicket/wicket-core
/**
* 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.millis(cookie.getMaxAge()).toDateString() + "(" + cookie.getMaxAge() + ")" + "]";
}
}
代码示例来源:origin: 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.millis(cookie.getMaxAge()).toDateString() + "(" + cookie.getMaxAge() + ")" + "]";
}
}
代码示例来源:origin: org.apache.wicket/wicket-util
@Override
public Time lastModifiedTime()
{
try
{
BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class);
FileTime lastModifiedTime = attributes.lastModifiedTime();
long millis = lastModifiedTime.toMillis();
return Time.millis(millis);
}
catch (IOException e)
{
throw new RuntimeException("Modification time of path " + path +
" could not be acquired", e);
}
}
代码示例来源:origin: org.geoserver.community/gs-web-resource
@Override
public Time lastModifiedTime() {
return Time.millis(resource.lastmodified());
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Returns a Time object representing the most recent time this file was modified.
*
* @return This file's lastModified() value as a Time object or <code>null</code> if
* that information is not available
*/
@Override
public Time lastModifiedTime()
{
final long time = lastModified();
if(time == 0)
{
return null;
}
return Time.millis(time);
}
代码示例来源:origin: org.apache.wicket/wicket-util
/**
* Retrieves a <code>Time</code> instance based on the given <code>Calendar</code> and
* {@link TimeOfDay} objects.
*
* @param calendar
* the <code>Calendar</code> to use
* @param timeOfDay
* the time of day
* @return a <code>Time</code> value for the time of day today
*/
public static Time valueOf(final Calendar calendar, final TimeOfDay timeOfDay)
{
synchronized (calendar)
{
// Set time to midnight today
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 0); // WICKET-2349
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0); // WICKET-1670
// Add time of day milliseconds to midnight
return millis(calendar.getTimeInMillis() + timeOfDay.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/wicket-util
/**
* 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 millis(getMilliseconds() + duration.getMilliseconds());
}
代码示例来源:origin: org.apache.wicket/wicket-util
return Time.millis(milliseconds);
代码示例来源: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/wicket-core
/**
* 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;
}
}
内容来源于网络,如有侵权,请联系作者删除!