java.util.Date.toGMTString()方法的使用及代码示例

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

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

Date.toGMTString介绍

[英]Returns the string representation of this Date in GMT in the format "22 Jun 1999 13:02:00 GMT".
[中]以GMT格式返回此日期的字符串表示形式,格式为“1999年6月22日13:02:00 GMT”。

代码示例

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

LOG.info("MOB HFiles older than " + expireDate.toGMTString() + " will be deleted!");

代码示例来源:origin: stackoverflow.com

Date expdate = new Date ();
expdate.setTime (expdate.getTime() + (3600 * 1000));
String cookieExpire = "expires=" + expdate.toGMTString();
...

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public String toString() {
  StringBuilder buf = new StringBuilder("QueryStats[query:");
  buf.append(query);
  buf.append(", nrOfInvocations:");
  buf.append(nrOfInvocations);
  buf.append(", maxInvocationTime:");
  buf.append(maxInvocationTime);
  buf.append(", maxInvocationDate:");
  buf.append(new java.util.Date(maxInvocationDate).toGMTString());
  buf.append(", minInvocationTime:");
  buf.append(minInvocationTime);
  buf.append(", minInvocationDate:");
  buf.append(new java.util.Date(minInvocationDate).toGMTString());
  buf.append(", totalInvocationTime:");
  buf.append(totalInvocationTime);
  buf.append(", averageInvocationTime:");
  buf.append((float)totalInvocationTime / (float)nrOfInvocations);
  buf.append(", failures:");
  buf.append(failures);
  buf.append(", prepareCount:");
  buf.append(prepareCount);
  buf.append(", prepareTime:");
  buf.append(prepareTime);
  buf.append("]");
  return buf.toString();
}

代码示例来源:origin: linkedin/flashback

private void writeHttpExchange(RecordedHttpExchange recordedHttpExchanges)
  throws IOException {
 _jsonGenerator.writeStringField(SceneSerializationConstant.SCENE_TAG_UPDATE_TIME,
   recordedHttpExchanges.getUpdateTime().toGMTString());
 _jsonGenerator.writeObjectFieldStart(SceneSerializationConstant.SCENE_TAG_HTTPREQUEST);
 writeHttpRequest(recordedHttpExchanges.getRecordedHttpRequest());
 _jsonGenerator.writeEndObject();
 _jsonGenerator.writeObjectFieldStart(SceneSerializationConstant.SCENE_TAG_HTTPRESPONSE);
 writeHttpResponse(recordedHttpExchanges.getRecordedHttpResponse());
 _jsonGenerator.writeEndObject();
}

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

Headers hds = t.getResponseHeaders();
hds.set("Content-Type", contentType);
hds.set("Last-Modified", new Date(lastModified).toGMTString());
t.sendResponseHeaders(200, length);
responseFileContent(t, f);

代码示例来源:origin: org.apache.slider/slider-core

/**
 * Convert an epoch time to a GMT time. This
 * uses the deprecated Date.toString() operation,
 * so is in one place to reduce the number of deprecation warnings.
 * @param time timestamp
 * @return string value as ISO-9601
 */
@SuppressWarnings({"CallToDateToString", "deprecation"})
public static String toGMTString(long time) {
 return new Date(time).toGMTString();
}

代码示例来源:origin: com.betfair.cougar/baseline-app

private String dateInUTC(Date date) {
  if (date == null) {
    return "null";
  }
  return date.toGMTString().replace("GMT","UTC");
}

代码示例来源:origin: com.betfair.cougar/cougar-test-utils

public String dateInUTC(Date date) {
    if (date == null) {
      return "null";
    }
    return date.toGMTString().replace("GMT","UTC");
  }
}

代码示例来源:origin: apache/incubator-slider

/**
 * Convert an epoch time to a GMT time. This
 * uses the deprecated Date.toString() operation,
 * so is in one place to reduce the number of deprecation warnings.
 * @param time timestamp
 * @return string value as ISO-9601
 */
@SuppressWarnings({"CallToDateToString", "deprecation"})
public static String toGMTString(long time) {
 return new Date(time).toGMTString();
}

代码示例来源:origin: terrier-org/terrier-core

/** This method prints out the last time this index was updated as a String in GMT format **/
@SuppressWarnings("deprecation")
public String getTimeOfLastUpdate() {
  currentCalendar.setTimeInMillis(lastUpdateTime);
  return currentCalendar.getTime().toGMTString();
}

代码示例来源:origin: stackoverflow.com

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
String dateStr = "2010-02-15T20:05:28.000Z";
try {
  Date date = format.parse(dateStr);
  System.out.println(date.toGMTString());
} catch (ParseException e) {
  e.printStackTrace();
}

代码示例来源:origin: stackoverflow.com

@Test
public void shouldParseDateCorrectly() throws Exception {
  // Given
  SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
  format.setTimeZone(TimeZone.getTimeZone("UTC"));

  // When
  Date parsedDate = format.parse("21/08/2012");

  // Then
  Assert.assertThat(parsedDate.toString(), is("Tue Aug 21 02:00:00 CEST 2012"));
  Assert.assertThat(parsedDate.toGMTString(), is("21 Aug 2012 00:00:00 GMT"));
}

代码示例来源:origin: stackoverflow.com

//date.setTimeZone(TimeZone.getTimeZone("UTC")); <- remove it.
 date.set(Calendar.HOUR_OF_DAY, 0);

GregorianCalendar utcCAL = (GregorianCalendar) GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
utcCAL.setTimeInMillis(date.getTimeInMillis());
System.out.println(utcCAL.getTime().toGMTString() + " " + utcCAL.getTimeInMillis());

代码示例来源:origin: stackoverflow.com

String ackwardDate = "/Date(1376841597000)/";
//Dirty convertion
Calendar calendar = Calendar.getInstance();
String ackwardRipOff = ackwardDate.replace("/Date(", "").replace(")/", "");
Long timeInMillis = Long.valueOf(ackwardRipOff);
calendar.setTimeInMillis(timeInMillis);
System.out.println(calendar.getTime().toGMTString()); //Prints 18 Aug 2013 15:59:57 GMT

代码示例来源:origin: edu.toronto.cs.savant/savant-analytics

private static NameValuePair[] dynamicKeyValues() {
  return new NameValuePair[]{
        nvp("client-time", (new Date()).toGMTString())
      };
}
private static final String UNDEFINED_VERSION = "";

代码示例来源:origin: stackoverflow.com

//date.setTimeZone(TimeZone.getTimeZone("UTC"));
date.set(Calendar.HOUR_OF_DAY, 0);
Date utcDate = date.getTime();
utcDate.UTC(2014, 9, 1, 26, 1, 0);
System.out.println(utcDate.toGMTString() + " " + date.getTimeInMillis());

代码示例来源:origin: EvoSuite/evosuite

@SuppressWarnings("deprecation")
public String toGMTString() {
  Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, this, "toGMTString", "()Ljava/lang/String;", new Object[] {});
  String ret = super.toGMTString();
  Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, this, ret);
  return ret;
}

代码示例来源:origin: org.apache.james.protocols/protocols-imap

@Test
@SuppressWarnings("deprecation")
public void testAppleMailPrependsZeroNotSpace() throws Exception {
  assertThat(DecoderUtils.decodeDateTime(
      "09-Apr-2008 15:17:51 +0200").toGMTString()).isEqualTo("9 Apr 2008 13:17:51 GMT");
}

代码示例来源:origin: xjdr/xio

@Test
public void testGetTimeMillis() {
 // TODO(CK): netty bug? we can't call addTimeMillis() here
 headers.delegate().add("header", new Date(1514400000L).toGMTString());
 assertEquals((Long) 1514400000L, headers.getTimeMillis("header"));
}

代码示例来源:origin: greenaddress/GreenBits

@SuppressWarnings("deprecation")
@Test
public void testDate() throws Exception {
  Block block = PARAMS.getDefaultSerializer().makeBlock(blockBytes);
  assertEquals("4 Nov 2010 16:06:04 GMT", block.getTime().toGMTString());
}

相关文章