gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-18 00:04:40 24 4
gpt4 key购买 nike

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

YearMonth.format介绍

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

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

代码示例

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

@Override
public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    g.writeStartArray();
    _serializeAsArrayContents(value, g, provider);
    g.writeEndArray();
    return;
  }
  g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
}

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

@Override
public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    g.writeStartArray();
    _serializeAsArrayContents(value, g, provider);
    g.writeEndArray();
    return;
  }
  g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
}

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

@Override
public void serializeWithType(YearMonth value, JsonGenerator g,
    SerializerProvider provider, TypeSerializer typeSer) throws IOException
{
  WritableTypeId typeIdDef = typeSer.writeTypePrefix(g,
      typeSer.typeId(value, serializationShape(provider)));
  // need to write out to avoid double-writing array markers
  if (typeIdDef.valueShape == JsonToken.START_ARRAY) {
    _serializeAsArrayContents(value, g, provider);
  } else {
    g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
  }
  typeSer.writeTypeSuffix(g, typeIdDef);
}

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

@Override
public void serializeWithType(YearMonth value, JsonGenerator g,
    SerializerProvider provider, TypeSerializer typeSer) throws IOException
{
  WritableTypeId typeIdDef = typeSer.writeTypePrefix(g,
      typeSer.typeId(value, serializationShape(provider)));
  // need to write out to avoid double-writing array markers
  if (typeIdDef.valueShape == JsonToken.START_ARRAY) {
    _serializeAsArrayContents(value, g, provider);
  } else {
    g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
  }
  typeSer.writeTypeSuffix(g, typeIdDef);
}

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

YearMonth source = YearMonth.now();
DateTimeFormatter english = DateTimeFormatter.ofPattern("MMMM, yyyy", Locale.ENGLISH);
DateTimeFormatter german = DateTimeFormatter.ofPattern("MMMM yyyy", Locale.GERMAN);

System.out.println(source.format(english));
System.out.println(source.format(german));

代码示例来源:origin: br.com.jarch/jarch-jsf

@Override
  public String getAsString(FacesContext context, UIComponent component, Object value) {
    if (value == null) {
      return null;
    }

    if (value.toString().isEmpty()) {
      return "";
    }

    YearMonth yearMonth = (YearMonth) value;
    return yearMonth.format(ofPattern("MM/yyyy"));
  }
}

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

YearMonth thisMonth    = YearMonth.now();
YearMonth lastMonth    = thisMonth.minusMonths(1);
YearMonth twoMonthsAgo = thisMonth.minusMonths(2);

DateTimeFormatter monthYearFormatter = DateTimeFormatter.ofPattern("MMMM yyyy");

System.out.printf("Today: %s\n", thisMonth.format(monthYearFormatter));
System.out.printf("Last Month: %s\n", lastMonth.format(monthYearFormatter));
System.out.printf("Two Months Ago: %s\n", twoMonthsAgo.format(monthYearFormatter));

代码示例来源:origin: OpenGamma/Strata

@ImmutablePreBuild
private static void preBuild(Builder builder) {
 if (builder.label == null && builder.yearMonth != null) {
  builder.label = builder.yearMonth.format(FORMATTER);
 }
}

代码示例来源:origin: OpenGamma/Strata

/**
 * Summarizes this ETD future into string form.
 *
 * @return the summary description
 */
public String summaryDescription() {
 return variant.getCode() + expiry.format(YM_FORMAT);
}

代码示例来源:origin: br.com.jarch/jarch-annotation

@Override
public String getValueInsertTest() {
  return YearMonth.now().format(DateTimeFormatter.ofPattern(MMYYYY));
}

代码示例来源:origin: org.opensingular/form-core

@Override
protected String toStringPersistence(YearMonth originalValue) {
  return originalValue == null ? null : originalValue.format(formatter());
}

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

public static void main(String[] args) {        
  DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM-yyyy", Locale.ENGLISH);
  YearMonth startDate = YearMonth.parse("Jan-2015", formatter);
  YearMonth endDate = YearMonth.parse("Apr-2015", formatter);

  while(startDate.isBefore(endDate)) {
    System.out.println(startDate.format(formatter));
    startDate = startDate.plusMonths(1);
  }
}

代码示例来源:origin: br.com.jarch/jarch-annotation

@Override
public String getValueChangeTest() {
  return YearMonth.now().minusMonths(2).format(DateTimeFormatter.ofPattern(MMYYYY));
}

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

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu.MM");
YearMonth date = YearMonth.parse("2010.01", formatter);
YearMonth end = YearMonth.parse("2010.05", formatter);
while (!date.isAfter(end)) {
  System.out.println(date.format(formatter));
  date = date.plusMonths(1);
}

代码示例来源:origin: br.com.jarch/jarch-annotation

@Override
public String getValueCloneTest() {
  return YearMonth.now().minusMonths(1).format(DateTimeFormatter.ofPattern(MMYYYY));
}

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

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

代码示例来源:origin: OpenGamma/Strata

/**
 * Obtains an instance using the year-month.
 * 
 * @param date  the date associated with the parameter
 * @param yearMonth  the year-month of the curve node
 * @return the parameter metadata based on the year-month
 */
public static YearMonthDateParameterMetadata of(LocalDate date, YearMonth yearMonth) {
 ArgChecker.notNull(date, "date");
 ArgChecker.notNull(yearMonth, "yearMonth");
 return new YearMonthDateParameterMetadata(date, yearMonth, yearMonth.format(FORMATTER));
}

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

@Override
public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    g.writeStartArray();
    _serializeAsArrayContents(value, g, provider);
    g.writeEndArray();
    return;
  }
  g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
}

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

@Override
public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    g.writeStartArray();
    _serializeAsArrayContents(value, g, provider);
    g.writeEndArray();
    return;
  }
  g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
}

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

@Override
public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException
{
  if (useTimestamp(provider)) {
    g.writeStartArray();
    _serializeAsArrayContents(value, g, provider);
    g.writeEndArray();
    return;
  }
  g.writeString((_formatter == null) ? value.toString() : value.format(_formatter));
}

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