本文整理了Java中java.time.ZonedDateTime.format()
方法的一些代码示例,展示了ZonedDateTime.format()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.format()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:format
[英]Outputs this date-time as a String using the formatter.
This date will be passed to the formatter DateTimeFormatter#format(TemporalAccessor).
[中]使用格式化程序将此日期时间作为字符串输出。
此日期将传递给格式化程序DateTimeFormatter#format(临时Accessor)。
代码示例来源:origin: apache/hive
@Override
public String toString() {
return zonedDateTime.format(TimestampTZUtil.FORMATTER);
}
代码示例来源:origin: lets-blade/blade
/**
* format unix time to string
*
* @param unixTime unix time
* @param pattern date format pattern
* @return return string date
*/
public static String toString(long unixTime, String pattern) {
return Instant.ofEpochSecond(unixTime).atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern(pattern));
}
代码示例来源:origin: lets-blade/blade
/**
* format unix time to string
*
* @param unixTime unix time
* @param pattern date format pattern
* @return return string date
*/
public static String toString(long unixTime, String pattern) {
return Instant.ofEpochSecond(unixTime).atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern(pattern));
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
return Instant.ofEpochMilli(millisUtc).atZone(ZoneId.of(timeZoneKey.getId())).format(formatter);
}
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
if (isLegacyTimestamp()) {
return Instant.ofEpochMilli(millis).atZone(ZoneId.of(sessionTimeZoneKey.get().getId())).format(formatter);
}
else {
return Instant.ofEpochMilli(millis).atZone(ZoneOffset.UTC).format(formatter);
}
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
return Instant.ofEpochMilli(millisUtc).atZone(ZoneId.of(timeZoneKey.getId())).format(formatter);
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public String prettyPrint()
{
return assertPrintable( () -> value.format( DateTimeFormatter.ISO_DATE_TIME ) );
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
if (isLegacyTimestamp()) {
return Instant.ofEpochMilli(millis).atZone(ZoneId.of(sessionTimeZoneKey.get().getId())).format(JSON_FORMATTER);
}
else {
return Instant.ofEpochMilli(millis).atZone(ZoneId.of(UTC_KEY.getId())).format(JSON_FORMATTER);
}
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
if (isLegacyTimestamp()) {
return Instant.ofEpochMilli(millis).atZone(ZoneId.of(sessionTimeZoneKey.get().getId())).format(formatter);
}
else {
return Instant.ofEpochMilli(millis).atZone(ZoneOffset.UTC).format(formatter);
}
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' + createdAt().format(DateTimeFormatter.ISO_DATE_TIME) + '}';
}
}
代码示例来源:origin: prestodb/presto
public static ParameterizedType makeClassName(String baseName, Optional<String> suffix)
{
String className = baseName
+ "_" + suffix.orElseGet(() -> Instant.now().atZone(UTC).format(TIMESTAMP_FORMAT))
+ "_" + CLASS_ID.incrementAndGet();
return typeFromJavaClassName("com.facebook.presto.$gen." + toJavaIdentifierString(className));
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
if (isLegacyTimestamp()) {
return Instant.ofEpochMilli(millis).atZone(ZoneId.of(sessionTimeZoneKey.get().getId())).format(JSON_FORMATTER);
}
else {
return Instant.ofEpochMilli(millis).atZone(ZoneId.of(UTC_KEY.getId())).format(JSON_FORMATTER);
}
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
return Instant.ofEpochMilli(millisUtc).atZone(ZoneId.of(timeZoneKey.getId())).format(formatter);
}
}
代码示例来源:origin: prestodb/presto
@JsonValue
@Override
public String toString()
{
return Instant.ofEpochMilli(millisUtc).atZone(ZoneId.of(timeZoneKey.getId())).format(formatter);
}
}
代码示例来源:origin: web3j/web3j
private static String getWalletFileName(WalletFile walletFile) {
DateTimeFormatter format = DateTimeFormatter.ofPattern(
"'UTC--'yyyy-MM-dd'T'HH-mm-ss.nVV'--'");
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
return now.format(format) + walletFile.getAddress() + ".json";
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Adds the date header for the given {@link ZonedDateTime}.
*
* @param date The local date time (will be converted to GMT) as per {@link DateTimeFormatter#RFC_1123_DATE_TIME}
* @return The {@link MutableHttpHeaders}
*/
default MutableHttpHeaders date(LocalDateTime date) {
if (date != null) {
add(DATE, ZonedDateTime.of(date, ZoneId.of("GMT")).format(DateTimeFormatter.RFC_1123_DATE_TIME));
}
return this;
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Adds the LAST_MODIFIED header for the given {@link ZonedDateTime}.
*
* @param date The local date time (will be converted to GMT) as per {@link DateTimeFormatter#RFC_1123_DATE_TIME}
* @return The {@link MutableHttpHeaders}
*/
default MutableHttpHeaders lastModified(LocalDateTime date) {
if (date != null) {
add(LAST_MODIFIED, ZonedDateTime.of(date, ZoneId.of("GMT")).format(DateTimeFormatter.RFC_1123_DATE_TIME));
}
return this;
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Adds the DATE header for the given {@link ZonedDateTime}.
*
* @param timeInMillis The current time in milli seconds
* @return The {@link MutableHttpHeaders}
*/
default MutableHttpHeaders date(long timeInMillis) {
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timeInMillis), ZoneId.of("GMT"));
add(DATE, date.format(DateTimeFormatter.RFC_1123_DATE_TIME));
return this;
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Adds the LAST_MODIFIED header for the given {@link ZonedDateTime}.
*
* @param timeInMillis The current time in milli seconds
* @return The {@link MutableHttpHeaders}
*/
default MutableHttpHeaders lastModified(long timeInMillis) {
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timeInMillis), ZoneId.of("GMT"));
add(LAST_MODIFIED, date.format(DateTimeFormatter.RFC_1123_DATE_TIME));
return this;
}
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Adds the EXPIRES header for the given {@link ZonedDateTime}.
*
* @param date The local date time (will be converted to GMT) as per {@link DateTimeFormatter#RFC_1123_DATE_TIME}
* @return The {@link MutableHttpHeaders}
*/
default MutableHttpHeaders expires(LocalDateTime date) {
if (date != null) {
add(EXPIRES, ZonedDateTime.of(date, ZoneId.of("GMT")).format(DateTimeFormatter.RFC_1123_DATE_TIME));
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!