當前位置: 首頁>>代碼示例>>Java>>正文


Java ZonedDateTime.format方法代碼示例

本文整理匯總了Java中java.time.ZonedDateTime.format方法的典型用法代碼示例。如果您正苦於以下問題:Java ZonedDateTime.format方法的具體用法?Java ZonedDateTime.format怎麽用?Java ZonedDateTime.format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.format方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getServerTime

import java.time.ZonedDateTime; //導入方法依賴的package包/類
private HelloResponseServertime getServerTime() {
    final ZonedDateTime now = ZonedDateTime.now();
    final String dateFormatted = now.format(DateTimeFormatter.ISO_INSTANT);

    final HelloResponseServertime serverTime = new HelloResponseServertime();
    serverTime.timestamp(new Date().getTime());
    serverTime.iso8601(dateFormatted);
    return serverTime;
}
 
開發者ID:apache,項目名稱:metamodel-membrane,代碼行數:10,代碼來源:RootInformationController.java

示例2: doLayout

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Override
public String doLayout(ILoggingEvent event) {
    Instant instant = Instant.ofEpochMilli(event.getTimeStamp());
    ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());
    StringBuilder log = new StringBuilder(dateTime.format(dateFormat));

    log.append(String.format(" %-5s", event.getLevel().levelStr));

    if (requireThread) {
        log.append(String.format(" [%s]", event.getThreadName()));
    }

    int lineNumber = event.getCallerData().length > 0 ? event.getCallerData()[0].getLineNumber() : 0;

    log.append(String.format(" %s:%d: ", event.getLoggerName(), lineNumber));

    ThrowableProxy proxy = (ThrowableProxy) event.getThrowableProxy();

    if (requireAlertLevel || requireErrorCode) {
        appendExtraExceptionFlags(log, AbstractLoggingException.getFromThrowableProxy(proxy));
    }

    log.append(event.getFormattedMessage()).append(CoreConstants.LINE_SEPARATOR);

    appendStackTrace(log, proxy);

    if (proxy != null) {
        loopCauses(log, proxy, 0);
    }

    return log.toString();
}
 
開發者ID:hmcts,項目名稱:java-logging,代碼行數:33,代碼來源:ReformLoggingLayout.java

示例3: sut_serializes_ZonedDateTime_as_iso_8601

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Test
public void sut_serializes_ZonedDateTime_as_iso_8601() {
    // Arrange
    ZonedDateTime dateTime = ZonedDateTime.now(Clock.systemUTC());
    MessageWithZonedDateTimeProperty message = new MessageWithZonedDateTimeProperty(dateTime);
    JacksonMessageSerializer sut = new JacksonMessageSerializer();

    // Act
    String actual = sut.serialize(message);
    System.out.println("The serialized value is '" + actual + "'.");

    // Assert
    String formatted = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);
    Assert.assertTrue(actual.contains("\"dateTime\":\"" + formatted + "\""));
}
 
開發者ID:loom,項目名稱:loom-core,代碼行數:16,代碼來源:JacksonMessageSerializerSpecs.java

示例4: vanZonedDateTimeNaarXsdDateTime

import java.time.ZonedDateTime; //導入方法依賴的package包/類
/**
 * @param zonedDateTime zonedDateTime
 * @return xsd datetime
 */
public static String vanZonedDateTimeNaarXsdDateTime(final ZonedDateTime zonedDateTime) {
    if (zonedDateTime == null) {
        return null;
    }
    return zonedDateTime.format(DATE_TIME_FORMATTER);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:11,代碼來源:DatumFormatterUtil.java

示例5: Credentials

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public Credentials(final BasicSessionCredentials credentials,
                   final ZonedDateTime expiration) {
    this.accessKeyId = credentials.getAWSAccessKeyId();
    this.secretAccessKey = credentials.getAWSSecretKey();
    this.sessionToken = credentials.getSessionToken();
    this.expiration = expiration.format(DateTimeFormatter.ISO_INSTANT);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:8,代碼來源:SessionCacheSchema.java

示例6: zonedDateTimeCompatibilityWithDateTimeFormatter

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Test
public void zonedDateTimeCompatibilityWithDateTimeFormatter() throws Exception {
	final ZonedDateTime out = ZonedDateTime.now();
	final String s = out.format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
	final ZonedDateTime in = VPackJdk8Deserializers.ZONED_DATE_TIME.deserialize(null,
		new VPackBuilder().add(s).slice(), null);
	assertThat(in, is(out));
}
 
開發者ID:arangodb,項目名稱:java-velocypack-module-jdk8,代碼行數:9,代碼來源:VPackTimeTest.java

示例7: getDateRangeFor

import java.time.ZonedDateTime; //導入方法依賴的package包/類
private static String getDateRangeFor(ZonedDateTime dateTime){
    String day = dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    String range= String.format("%sT00:00:00.000Z,%sT23:59:59.000Z", day, day);
    return range;
}
 
開發者ID:gchq,項目名稱:stroom-stats,代碼行數:6,代碼來源:QueryResource_simpleQueries_IT.java

示例8: convert

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Override
public String convert(ZonedDateTime source) {
    return source.format(FORMATTER);
}
 
開發者ID:n15g,項目名稱:spring-boot-gae,代碼行數:5,代碼來源:ZonedDateTimeToStringConverter.java

示例9: toFileSaveFormat

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public static String toFileSaveFormat(@Nonnull ZonedDateTime zdt) {
  return zdt.format(fileSaveFormat);
}
 
開發者ID:EHRI,項目名稱:rs-aggregator,代碼行數:4,代碼來源:ZonedDateTimeUtil.java

示例10: getFormatDate

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public String getFormatDate(ZonedDateTime dateTime) {
    DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");

    return dateTime.format(format);
}
 
開發者ID:ugouku,項目名稱:shoucang,代碼行數:6,代碼來源:ViewUtils.java

示例11: serialize

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public JsonElement serialize(ZonedDateTime date, Type typeOfSrc, JsonSerializationContext context) {
	return new JsonPrimitive(date.format(DateTimeFormatter.ISO_DATE_TIME));
}
 
開發者ID:mgustavocoder,項目名稱:hard-worker-activity-stream,代碼行數:4,代碼來源:ActController.java

示例12: nowUTC

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public static String nowUTC() {
    ZonedDateTime localNow = ZonedDateTime.now();
    ZonedDateTime utcNow = localNow.withZoneSameInstant(utc);
    return utcNow.format(comparableFormatter);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:6,代碼來源:FormattedTimestamp.java

示例13: from

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public static String from(ZonedDateTime timestamp) {
    return timestamp.format(comparableFormatter);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:4,代碼來源:FormattedTimestamp.java

示例14: toHumanReadable

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public static String toHumanReadable(ZonedDateTime timestamp) {
    return timestamp.format(humanReadableFormatter);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:4,代碼來源:FormattedTimestamp.java


注:本文中的java.time.ZonedDateTime.format方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。