org.apache.shindig.common.util.DateUtil.formatRfc1123Date()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(245)

本文整理了Java中org.apache.shindig.common.util.DateUtil.formatRfc1123Date()方法的一些代码示例,展示了DateUtil.formatRfc1123Date()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.formatRfc1123Date()方法的具体详情如下:
包路径:org.apache.shindig.common.util.DateUtil
类名称:DateUtil
方法名:formatRfc1123Date

DateUtil.formatRfc1123Date介绍

[英]Formats an RFC 1123 format date.
[中]设置RFC 1123格式日期的格式。

代码示例

代码示例来源:origin: org.apache.shindig/shindig-common

/**
 * Formats an RFC 1123 format date.
 */
public static String formatRfc1123Date(Date date) {
 return formatRfc1123Date(date.getTime());
}

代码示例来源:origin: com.lmco.shindig/shindig-common

/**
 * Formats an RFC 1123 format date.
 */
public static String formatRfc1123Date(Date date) {
 return formatRfc1123Date(date.getTime());
}

代码示例来源:origin: apache/shindig

/**
 * Formats an RFC 1123 format date.
 */
public static String formatRfc1123Date(Date date) {
 return formatRfc1123Date(date.getTime());
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common

@Override
public void addDateHeader(String name, long date) {
 headers.put(name, DateUtil.formatRfc1123Date(date));
}

代码示例来源:origin: org.gatein.shindig/shindig-common

@Test
public void format() {
 for (int i = 0, j = timeStamps.length; i < j; ++i) {
  assertEquals(rfc1123text[i], DateUtil.formatRfc1123Date(timeStamps[i].getTime()));
 }
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void format() {
 for (int i = 0, j = timeStamps.length; i < j; ++i) {
  assertEquals(rfc1123text[i], DateUtil.formatRfc1123Date(timeStamps[i].getTime()));
 }
}

代码示例来源:origin: org.apache.shindig/shindig-common

@Test
public void formatRfc1123Date() {
 for (int i = 0, j = timeStamps.length; i < j; ++i) {
  assertEquals(rfc1123text[i], DateUtil.formatRfc1123Date(timeStamps[i]));
 }
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-common

@Test
public void formatRfc1123Date() {
 for (int i = 0, j = timeStamps.length; i < j; ++i) {
  assertEquals(rfc1123text[i], DateUtil.formatRfc1123Date(timeStamps[i]));
 }
}

代码示例来源:origin: com.lmco.shindig/shindig-common

@Test
public void formatRfc1123Date() {
 for (int i = 0, j = timeStamps.length; i < j; ++i) {
  assertEquals(rfc1123text[i], DateUtil.formatRfc1123Date(timeStamps[i]));
 }
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void testFixedDate() throws Exception {
 int time = roundToSeconds(timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
   .addHeader("Date", DateUtil.formatRfc1123Date(1000L * time))
   .create();
 assertEquals(time + roundToSeconds(response.getDefaultTtl()),
   roundToSeconds(response.getCacheExpiration()));
 assertEquals(DateUtil.formatRfc1123Date(timeSource.currentTimeMillis()),
   response.getHeader("Date"));
 assertTtlOk(roundToSeconds(response.getDefaultTtl()), response);
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testFixedDate() throws Exception {
 int time = roundToSeconds(timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
   .addHeader("Date", DateUtil.formatRfc1123Date(1000L * time))
   .create();
 assertEquals(time + roundToSeconds(response.getDefaultTtl()),
   roundToSeconds(response.getCacheExpiration()));
 assertEquals(DateUtil.formatRfc1123Date(timeSource.currentTimeMillis()),
   response.getHeader("Date"));
 assertTtlOk(roundToSeconds(response.getDefaultTtl()), response);
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void testFixedDateOk() throws Exception {
 int time = roundToSeconds(HttpResponseTest.timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
     .addHeader(
         "Date",
         DateUtil.formatRfc1123Date(1000L * time + 1000
             - DefaultRequestPipeline.DEFAULT_DRIFT_LIMIT_MS)).setCacheTtl(100)
     .create();
 HttpResponse newResponse = DefaultRequestPipeline.maybeFixDriftTime(response);
 assertSame(response, newResponse);
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testFixedDateOk() throws Exception {
 int time = roundToSeconds(HttpResponseTest.timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
     .addHeader(
         "Date",
         DateUtil.formatRfc1123Date(1000L * time + 1000
             - DefaultRequestPipeline.DEFAULT_DRIFT_LIMIT_MS)).setCacheTtl(100)
     .create();
 HttpResponse newResponse = DefaultRequestPipeline.maybeFixDriftTime(response);
 assertSame(response, newResponse);
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void testShouldRefetchForStrictNoCacheResponsePastShouldNotRefetch() throws Exception {
 assertEquals(false, new HttpResponseBuilder().setStrictNoCache()
   .setHeader("Date",
     DateUtil.formatRfc1123Date(HttpUtil.getTimeSource().currentTimeMillis() - 5000))
   .setRefetchStrictNoCacheAfterMs(10000)
   .create()
   .shouldRefetch());
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testShouldRefetchForStrictNoCacheResponsePastShouldNotRefetch() throws Exception {
 assertEquals(false, new HttpResponseBuilder().setStrictNoCache()
   .setHeader("Date",
     DateUtil.formatRfc1123Date(HttpUtil.getTimeSource().currentTimeMillis() - 5000))
   .setRefetchStrictNoCacheAfterMs(10000)
   .create()
   .shouldRefetch());
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void testShouldRefetchForStrictNoCacheResponsePastShouldRefetch() throws Exception {
 assertEquals(true, new HttpResponseBuilder().setStrictNoCache()
   .setHeader("Date",
     DateUtil.formatRfc1123Date(HttpUtil.getTimeSource().currentTimeMillis() - 20000))
   .setRefetchStrictNoCacheAfterMs(10000)
   .create()
   .shouldRefetch());
}

代码示例来源:origin: com.lmco.shindig/shindig-gadgets

@Test
public void testMaxAgeWithDate() throws Exception {
 int maxAge = 10;
 int now = roundToSeconds(timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
   .addHeader("Date", DateUtil.formatRfc1123Date(1000L * now))
   .addHeader("Cache-Control", "public, max-age=" + maxAge)
   .create();
 assertEquals(now + maxAge, roundToSeconds(response.getCacheExpiration()));
 assertTtlOk(maxAge, response);
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void testMaxAgeWithDate() throws Exception {
 int maxAge = 10;
 int now = roundToSeconds(timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
   .addHeader("Date", DateUtil.formatRfc1123Date(1000L * now))
   .addHeader("Cache-Control", "public, max-age=" + maxAge)
   .create();
 assertEquals(now + maxAge, roundToSeconds(response.getCacheExpiration()));
 assertTtlOk(maxAge, response);
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void testSetNoCache() {
 int time = roundToSeconds(timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
   .addHeader("Expires", DateUtil.formatRfc1123Date(1000L * time))
   .setStrictNoCache()
   .create();
 assertNull(response.getHeader("Expires"));
 assertEquals("no-cache", response.getHeader("Pragma"));
 assertEquals("no-cache", response.getHeader("Cache-Control"));
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testSetNoCache() {
 int time = roundToSeconds(timeSource.currentTimeMillis());
 HttpResponse response = new HttpResponseBuilder()
   .addHeader("Expires", DateUtil.formatRfc1123Date(1000L * time))
   .setStrictNoCache()
   .create();
 assertNull(response.getHeader("Expires"));
 assertEquals("no-cache", response.getHeader("Pragma"));
 assertEquals("no-cache", response.getHeader("Cache-Control"));
}

相关文章