当前位置: 首页>>代码示例>>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;未经允许,请勿转载。