gpt4 book ai didi

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

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

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

YearMonth.getYear介绍

[英]Gets the year field.

This method returns the primitive int value for the year.

The year returned by this method is proleptic as per get(YEAR).
[中]获取年份字段。
此方法返回该年的原始int值。
根据get(年),此方法返回的年份是proleptic。

代码示例

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

protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
    SerializerProvider provider) throws IOException
{
  g.writeNumber(value.getYear());
  g.writeNumber(value.getMonthValue());
}

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

protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
    SerializerProvider provider) throws IOException
{
  g.writeNumber(value.getYear());
  g.writeNumber(value.getMonthValue());
}

代码示例来源:origin: wildfly/wildfly

@Override
public void writeObject(ObjectOutput output, YearMonth value) throws IOException {
  output.writeInt(value.getYear());
  DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth());
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
  return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}

代码示例来源:origin: jfoenixadmin/JFoenix

private void goToDayCell(DateCell dateCell, int offset, ChronoUnit unit, boolean focusDayCell) {
  YearMonth yearMonth = selectedYearMonth.get().plus(offset, unit);
  goToDate(dayCellDate(dateCell).plus(offset, unit).withYear(yearMonth.getYear()), focusDayCell);
}

代码示例来源:origin: apache/tinkerpop

@Override
  protected ByteBuf writeValue(final YearMonth value, final ByteBufAllocator allocator, final GraphBinaryWriter context) throws SerializationException {
    return allocator.buffer(2).writeInt(value.getYear()).writeByte(value.getMonthValue());
  }
}

代码示例来源:origin: ebean-orm/ebean

protected LocalDate toLocalDate(YearMonth yearMonth) {
 return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1);
}

代码示例来源:origin: pholser/junit-quickcheck

@Override public YearMonth generate(SourceOfRandomness random, GenerationStatus status) {
    long generated = random.nextLong(
      min.getYear() * 12L + min.getMonthValue() - 1,
      max.getYear() * 12L + max.getMonthValue() - 1);

    return YearMonth.of(
      (int) (generated / 12),
      (int) Math.abs(generated % 12) + 1);
  }
}

代码示例来源:origin: diffplug/spotless

/** The license that we'd like enforced. */
private LicenseHeaderStep(String licenseHeader, String delimiter, String yearSeparator) {
  if (delimiter.contains("\n")) {
    throw new IllegalArgumentException("The delimiter must not contain any newlines.");
  }
  // sanitize the input license
  licenseHeader = LineEnding.toUnix(licenseHeader);
  if (!licenseHeader.endsWith("\n")) {
    licenseHeader = licenseHeader + "\n";
  }
  this.licenseHeader = licenseHeader;
  this.delimiterPattern = Pattern.compile('^' + delimiter, Pattern.UNIX_LINES | Pattern.MULTILINE);
  this.hasYearToken = licenseHeader.contains("$YEAR");
  if (this.hasYearToken) {
    int yearTokenIndex = licenseHeader.indexOf("$YEAR");
    this.licenseHeaderBeforeYearToken = licenseHeader.substring(0, yearTokenIndex);
    this.licenseHeaderAfterYearToken = licenseHeader.substring(yearTokenIndex + 5, licenseHeader.length());
    this.licenseHeaderWithYearTokenReplaced = licenseHeader.replace("$YEAR", String.valueOf(YearMonth.now().getYear()));
    this.yearMatcherPattern = Pattern.compile("[0-9]{4}(" + Pattern.quote(yearSeparator) + "[0-9]{4})?");
  }
}

代码示例来源:origin: apache/tinkerpop

@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final YearMonth monthDay) {
  output.writeInt(monthDay.getYear());
  output.writeInt(monthDay.getMonthValue());
}

代码示例来源:origin: diffplug/spotless

private String currentYear() {
  return String.valueOf(YearMonth.now().getYear());
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-driver

@Override
  public ByteBuf writeValue(final YearMonth value, final ByteBufAllocator allocator, final GraphBinaryWriter context) throws SerializationException {
    return allocator.buffer(2).writeInt(value.getYear()).writeByte(value.getMonthValue());
  }
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

@Override
  public void actionPerformed(ActionEvent e) {
    drawCalendar(displayedYearMonth.getYear(),
        Month.of(localMonthZeroBasedIndex + 1));
  }
}));

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

public static void main(String[] args) {
  for (int i = 5; i >= 0; i--) {
    YearMonth date = YearMonth.now().minusMonths(i);
    String monthName = date.getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH);
    System.out.println(monthName + "(" + date.getYear() + ")");
  }
}

代码示例来源:origin: diffplug/spotless

@Test
  public void testWithNonStandardYearSeparator() throws IOException {
    setFile("build.gradle").toLines(
        "plugins {",
        "    id 'nebula.kotlin' version '1.0.6'",
        "    id 'com.diffplug.gradle.spotless'",
        "}",
        "repositories { mavenCentral() }",
        "spotless {",
        "    kotlin {",
        "        licenseHeader('" + HEADER_WITH_YEAR + "').yearSeparator(', ')",
        "        ktlint()",
        "    }",
        "}");

    setFile("src/main/kotlin/test.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader.test");
    setFile("src/main/kotlin/test2.kt").toResource("kotlin/licenseheader/KotlinCodeWithMultiYearHeader2.test");
    gradleRunner().withArguments("spotlessApply").build();
    assertFile("src/main/kotlin/test.kt").matches(matcher -> {
      matcher.startsWith("// License Header 2012, 2014");
    });
    assertFile("src/main/kotlin/test2.kt").matches(matcher -> {
      matcher.startsWith(HEADER_WITH_YEAR.replace("$YEAR", String.valueOf(YearMonth.now().getYear())));
    });
  }
}

代码示例来源:origin: com.pholser/junit-quickcheck-generators

@Override public YearMonth generate(SourceOfRandomness random, GenerationStatus status) {
    long generated = random.nextLong(
      min.getYear() * 12L + min.getMonthValue() - 1,
      max.getYear() * 12L + max.getMonthValue() - 1);

    return YearMonth.of(
      (int) (generated / 12),
      (int) Math.abs(generated % 12) + 1);
  }
}

代码示例来源:origin: io.permazen/permazen-coreapi

@Override
public void write(ByteWriter writer, YearMonth yearMonth) {
  Preconditions.checkArgument(yearMonth != null, "null yearMonth");
  Preconditions.checkArgument(writer != null);
  LongEncoder.write(writer, yearMonth.getYear());
  LongEncoder.write(writer, yearMonth.getMonthValue());
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public LocalDate convert(YearMonth in, Context context) throws Exception {
    if (in == null) return null;
    return LocalDate.fromYearMonthDay(in.getYear(), in.getMonthValue(), 1);
  }
});

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

public Integer getAno() {
  if (isEmptyOfData()) {
    return null;
  }
  return getValue().getYear();
}

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

protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
    SerializerProvider provider) throws IOException
{
  g.writeNumber(value.getYear());
  g.writeNumber(value.getMonthValue());
}

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