当前位置: 首页>>代码示例>>Java>>正文


Java Time类代码示例

本文整理汇总了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;
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:17,代码来源:PhlocCssHtmlNotificationCssServiceImpl.java

示例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>");
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:17,代码来源:WicketRedirectStrategy.java

示例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());
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:23,代码来源:BasePage.java

示例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)));
}
 
开发者ID:l0rdn1kk0n,项目名称:wicket-clientside-logging,代码行数:21,代码来源:IParamValueExtractorTest.java

示例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;
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:16,代码来源:ArtifactoryWebRequest.java

示例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;
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:32,代码来源:UserPictureResource.java

示例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;
}
 
开发者ID:apache,项目名称:syncope,代码行数:9,代码来源:BinaryPDFPreviewer.java

示例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);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:7,代码来源:HeaderBufferingWebResponse.java

示例9: setDateHeader

import org.apache.wicket.util.time.Time; //导入依赖的package包/类
@Override
public void setDateHeader(String name, Time date) {
    originalResponse.setDateHeader(name, date);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:5,代码来源:IgnoreEofWebResponse.java

示例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);
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:44,代码来源:ListUsersPage.java


注:本文中的org.apache.wicket.util.time.Time类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。