本文整理汇总了Java中org.apache.wicket.util.time.Time类的典型用法代码示例。如果您正苦于以下问题:Java Time类的具体用法?Java Time怎么用?Java Time使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Time类属于org.apache.wicket.util.time包,在下文中一共展示了Time类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRegistry
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
private synchronized IHtmlNotificationCssRegistry getRegistry(LessCssResourceReference cssResourceReference) throws ServiceException {
IResourceStream resourceStream = cssResourceReference.getResource().getResourceStream();
if (resourceStream == null) { // NOSONAR findbugs:RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
throw new ServiceException("Could not retrieve resource stream for resource reference " + cssResourceReference + " when accessing a notification CSS style registry");
}
Time currentResourceLastModifiedTime = resourceStream.lastModifiedTime();
Pair<IHtmlNotificationCssRegistry, Time> cacheEntry = registryCache.get(cssResourceReference);
if (cacheEntry != null && cacheEntry.getRight().equals(currentResourceLastModifiedTime)) {
return cacheEntry.getLeft();
} else {
IHtmlNotificationCssRegistry registry = createRegistry(resourceStream);
registryCache.put(cssResourceReference, Pair.of(registry, currentResourceLastModifiedTime));
return registry;
}
}
示例2: sendRedirect
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@Override
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException {
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("text/xml");
response.setHeader("Ajax-Location", url);
// disabled caching
response.setHeader("Date", Long.toString(Time.now().getMilliseconds()));
response.setHeader("Expires", Long.toString(Time.START_OF_UNIX_TIME.getMilliseconds()));
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache, no-store");
Writer writer = response.getWriter();
writer.write("<ajax-response><redirect><![CDATA[" + url + "]]></redirect></ajax-response>");
}
示例3: setLastModified
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
/**
* Sets the last-modified header field and the expires field.
*
* @param when
*/
protected final void setLastModified(Date when) {
if (when == null) {
return;
}
if (when.before(app().getBootDate())) {
// last-modified can not be before the Gitblit boot date
// this helps ensure that pages are properly refreshed after a
// server config change
when = app().getBootDate();
}
int expires = app().settings().getInteger(Keys.web.pageCacheExpires, 0);
WebResponse response = (WebResponse) getResponse();
response.setLastModifiedTime(Time.valueOf(when));
response.setDateHeader("Expires", System.currentTimeMillis() + Duration.minutes(expires).getMilliseconds());
}
示例4: logMessagesWillBeExtracted
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@Test
public void logMessagesWillBeExtracted() {
IParamValueExtractor extractor = new IParamValueExtractor.DefaultParamValueExtractor();
MockRequestParameters params = new MockRequestParameters();
addMessage(1, params, "error", "message 1", Time.valueOf(new Date(1982, 12, 14, 8, 0)).getMilliseconds(), "file1", "line1", "stacktrace 1");
addMessage(2, params, "error", "message 2", Time.valueOf(new Date(1982, 12, 14, 12, 0)).getMilliseconds(), "file2", "line2", "stacktrace 2");
addMessage(3, params, "error", "message 3", Time.valueOf(new Date(1982, 12, 14, 16, 0)).getMilliseconds(), "file3", "line3", "stacktrace 3");
params.setParameterValue(ParamNames.LEVEL + "_" + 4, "warn");
params.setParameterValue(ParamNames.MESSAGE + "_" + 5, "message 5");
params.setParameterValue(ParamNames.TIMESTAMP + "_" + 6, "timestamp 6");
IParamValueExtractor.Result result = extractor.parse(params);
assertThat(Lists.newArrayList(result.logObjects()).size(), is(equalTo(3)));
assertThat(result.logObjects(), hasItem(new ClientSideLogObject("error", "message 1", Time.valueOf(new Date(1982, 12, 14, 8, 0)).getMilliseconds(), "file1", "line1", "stacktrace 1", 1)));
assertThat(result.logObjects(), hasItem(new ClientSideLogObject("error", "message 2", Time.valueOf(new Date(1982, 12, 14, 12, 0)).getMilliseconds(), "file2", "line2", "stacktrace 2", 2)));
assertThat(result.logObjects(), hasItem(new ClientSideLogObject("error", "message 3", Time.valueOf(new Date(1982, 12, 14, 16, 0)).getMilliseconds(), "file3", "line3", "stacktrace 3", 3)));
}
示例5: getDateHeader
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@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;
}
}
示例6: getImageData
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@Override
protected byte[] getImageData(Attributes attributes) {
Long attrUserId = getUserId(attributes);
int attrMaxSize = getMaxDimension(attributes);
try {
BufferedImage im;
BufferedImage thumb;
Path userPicturePath = UserProfilePictureUploadHelper.getUserPicturePath(attrUserId);
if (attrUserId != null && userPicturePath != null) {
im = ImageIO.read(userPicturePath.toFile());
setLastModifiedTime(Time.millis(userPicturePath.toFile().lastModified()));
} else {
setLastModifiedTime(Time.millis(75675677));
im = ImageIO.read(defaultProfilePictureRef.getCacheableResourceStream().getInputStream());
}
if (im.getWidth() > attrMaxSize || im.getHeight() > attrMaxSize) {
// TODO add caching, currently every request scales the image!!
thumb = Scalr.resize(im, Scalr.Method.ULTRA_QUALITY, Scalr.Mode.AUTOMATIC, attrMaxSize);
} else {
thumb = im;
}
byte[] bytes;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
ImageIO.write(thumb, "PNG", baos);
bytes = baos.toByteArray();
}
return bytes;
} catch (IOException | ResourceStreamNotFoundException ignored) {
}
return null;
}
示例7: getImageData
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@Override
protected byte[] getImageData(final IResource.Attributes attributes) {
if (thumbnail == null) {
thumbnail = toImageData(getScaledImageInstance());
setLastModifiedTime(Time.now());
}
return thumbnail;
}
示例8: setDateHeader
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@Override
public void setDateHeader(String name, Time date) {
Args.notNull(date, "date");
checkHeader();
bufferedResponse.setDateHeader(name, date);
}
示例9: setDateHeader
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@Override
public void setDateHeader(String name, Time date) {
originalResponse.setDateHeader(name, date);
}
示例10: downloadHtopTable
import org.apache.wicket.util.time.Time; //导入依赖的package包/类
private void downloadHtopTable(Item<UIUserForList> item, final UIUserForList user) {
Link<Void> downloadHotpTableLink = new Link<Void>("download-hotp-table") {
@Override
public void onClick() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
hotpProvider.outputSequenceForDownload(user.getUsername(), os);
} catch (IOException e) {
throw new IllegalStateException(e);
}
final byte[] bytes = os.toByteArray();
IResourceStream resourceStream = new AbstractResourceStream() {
@Override
public Time lastModifiedTime() {
return Time.now();
}
@Override
public Bytes length() {
return Bytes.bytes(bytes.length);
}
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
return new ByteArrayInputStream(bytes);
}
@Override
public String getContentType() {
return "application/vnd.ms-excel";
}
@Override
public void close() throws IOException {
}
};
getRequestCycle().replaceAllRequestHandlers(new ResourceStreamRequestHandler(resourceStream,
hotpProvider.getSequenceForDownloadFileName(user.getUsername())));
}
};
downloadHotpTableLink.setVisible(hotpProvider.outputsSequenceForDownload());
item.add(downloadHotpTableLink);
}