gpt4 book ai didi

java.time.Year.format()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 23:20:40 26 4
gpt4 key购买 nike

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

Year.format介绍

[英]Outputs this year as a String using the formatter.

This year will be passed to the formatter DateTimeFormatter#format(TemporalAccessor).
[中]今年使用格式化程序以字符串形式输出。
今年将传递给格式化程序DateTimeFormatter#format(TemporalAccessor)。

代码示例

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-jsr310

@Override
public void serialize(Year year, JsonGenerator generator, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    generator.writeNumber(year.getValue());
  } else {
    String str = (_formatter == null) ? year.toString() : year.format(_formatter);
    generator.writeString(str);
  }
}

代码示例来源:origin: prestodb/presto

@Override
public void serialize(Year year, JsonGenerator generator, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    generator.writeNumber(year.getValue());
  } else {
    String str = (_formatter == null) ? year.toString() : year.format(_formatter);
    generator.writeString(str);
  }
}

代码示例来源:origin: FasterXML/jackson-datatype-jsr310

@Override
public void serialize(Year year, JsonGenerator generator, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    generator.writeNumber(year.getValue());
  } else {
    String str = (_formatter == null) ? year.toString() : year.format(_formatter);
    generator.writeString(str);
  }
}

代码示例来源:origin: amedia/freemarker-java-8

@Override
  public Object exec(List list) throws TemplateModelException {
    return getObject().format(createDateTimeFormatter(list, 0, "yyyy"));
  }
}

代码示例来源:origin: org.mycore.mir/mir-module

private static String getFormatedDateString(String date, DateTimeFormatter formatter) {
    TemporalAccessor ta = formatter.parseBest(date,
      LocalDateTime::from, LocalDate::from, YearMonth::from, Year::from);
    if (ta instanceof LocalDateTime) {
      LocalDateTime ld = LocalDateTime.from(ta);
      return ld.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
    }
    if (ta instanceof LocalDate) {
      LocalDate ld = LocalDate.from(ta);
      return ld.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }
    if (ta instanceof YearMonth) {
      YearMonth ld = YearMonth.from(ta);
      return ld.format(DateTimeFormatter.ofPattern("yyyy-MM"));
    }
    if (ta instanceof Year) {
      Year ld = Year.from(ta);
      return ld.format(DateTimeFormatter.ofPattern("yyyy"));
    }
    return date;
  }
}

代码示例来源:origin: com.facebook.presto/presto-jdbc

@Override
public void serialize(Year year, JsonGenerator generator, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    generator.writeNumber(year.getValue());
  } else {
    String str = (_formatter == null) ? year.toString() : year.format(_formatter);
    generator.writeString(str);
  }
}

代码示例来源:origin: io.prestosql/presto-jdbc

@Override
public void serialize(Year year, JsonGenerator generator, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    generator.writeNumber(year.getValue());
  } else {
    String str = (_formatter == null) ? year.toString() : year.format(_formatter);
    generator.writeString(str);
  }
}

代码示例来源:origin: prestosql/presto

@Override
public void serialize(Year year, JsonGenerator generator, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    generator.writeNumber(year.getValue());
  } else {
    String str = (_formatter == null) ? year.toString() : year.format(_formatter);
    generator.writeString(str);
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com