gpt4 book ai didi

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

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

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

Year.getValue介绍

[英]Gets the year value.

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

代码示例

代码示例来源: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: debezium/debezium

if (data instanceof java.time.Year) {
  r.deliver(adjustYear(((java.time.Year) data).getValue()));

代码示例来源:origin: kiegroup/optaplanner

@Test(expected = IllegalArgumentException.class)
public void remainderOnIncrementTypeExceedsMaximumYear() {
  Year from = Year.of(Year.MIN_VALUE);
  Year to = Year.of(Year.MAX_VALUE - 0);
  assertNotEquals(0, (to.getValue() - from.getValue()) % 10); // Maximum Year range is not divisible by 10
  assertNotNull(new TemporalValueRange<>(from, to, 1, ChronoUnit.DECADES));
}

代码示例来源:origin: kiegroup/optaplanner

private void writeTimeGrainDaysHeaders() {
  Day previousTimeGrainDay = null;
  int mergeStart = -1;
  for (TimeGrain timeGrain : solution.getTimeGrainList()) {
    Day timeGrainDay = timeGrain.getDay();
    if (timeGrainDay.equals(previousTimeGrainDay)) {
      nextHeaderCell("");
    } else {
      if (previousTimeGrainDay != null) {
        currentSheet.addMergedRegion(new CellRangeAddress(currentRowNumber, currentRowNumber, mergeStart, currentColumnNumber));
      }
      nextHeaderCell(DAY_FORMATTER.format(
          LocalDate.ofYearDay(Year.now().getValue(), timeGrainDay.getDayOfYear())));
      previousTimeGrainDay = timeGrainDay;
      mergeStart = currentColumnNumber;
    }
  }
  if (previousTimeGrainDay != null) {
    currentSheet.addMergedRegion(new CellRangeAddress(currentRowNumber, currentRowNumber, mergeStart, currentColumnNumber));
  }
}

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

@Override
public void jsonWrite(JsonGenerator writer, Year value) throws IOException {
 writer.writeNumber(value.getValue());
}

代码示例来源:origin: kiegroup/optaplanner

private void writeDays() {
  nextSheet("Days", 1, 1, false);
  nextRow();
  nextHeaderCell("Day");
  nextHeaderCell("Start");
  nextHeaderCell("End");
  nextHeaderCell("Lunch hour start time");
  for (Day dayOfYear : solution.getDayList()) {
    nextRow();
    LocalDate date = LocalDate.ofYearDay(Year.now().getValue(), dayOfYear.getDayOfYear());
    int startMinuteOfDay = 24 * 60, endMinuteOfDay = 0;
    for (TimeGrain timeGrain : solution.getTimeGrainList()) {
      if (timeGrain.getDay().equals(dayOfYear)) {
        startMinuteOfDay = timeGrain.getStartingMinuteOfDay() < startMinuteOfDay ?
            timeGrain.getStartingMinuteOfDay() : startMinuteOfDay;
        endMinuteOfDay = timeGrain.getStartingMinuteOfDay() + TimeGrain.GRAIN_LENGTH_IN_MINUTES > endMinuteOfDay ?
            timeGrain.getStartingMinuteOfDay() + TimeGrain.GRAIN_LENGTH_IN_MINUTES : endMinuteOfDay;
      }
    }
    LocalTime startTime = LocalTime.ofSecondOfDay(startMinuteOfDay * 60);
    LocalTime endTime = LocalTime.ofSecondOfDay(endMinuteOfDay * 60);
    LocalTime lunchHourStartTime = LocalTime.ofSecondOfDay(12 * 60 * 60); // 12pm
    nextCell().setCellValue(DAY_FORMATTER.format(date));
    nextCell().setCellValue(TIME_FORMATTER.format(startTime));
    nextCell().setCellValue(TIME_FORMATTER.format(endTime));
    nextCell().setCellValue(TIME_FORMATTER.format(lunchHourStartTime));
  }
  autoSizeColumnsWithHeader();
}

代码示例来源:origin: odrotbohm/spring-restbucks

/**
 * Returns the {@link LocalDate} the {@link CreditCard} expires.
 * 
 * @return will never be {@literal null}.
 */
public LocalDate getExpirationDate() {
  return LocalDate.of(expiryYear.getValue(), expiryMonth, 1);
}

代码示例来源:origin: org.mybatis/mybatis

@Override
public void setNonNullParameter(PreparedStatement ps, int i, Year year, JdbcType type) throws SQLException {
  ps.setInt(i, year.getValue());
}

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

@Override
public void writeData(DataOutput dataOutput, Year value) throws IOException {
 if (value == null) {
  dataOutput.writeBoolean(false);
 } else {
  dataOutput.writeBoolean(true);
  dataOutput.writeInt(value.getValue());
 }
}

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

@Override
public Object toJdbcType(Object value) {
 if (value instanceof Year) return ((Year) value).getValue();
 return BasicTypeConverter.toInteger(value);
}

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

@Override public Year generate(SourceOfRandomness random, GenerationStatus status) {
    return Year.of(random.nextInt(min.getValue(), max.getValue()));
  }
}

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

@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Year year) {
  output.writeInt(year.getValue());
}

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

@Override
public void bind(DataBind bind, Year value) throws SQLException {
 if (value == null) {
  bind.setNull(Types.INTEGER);
 } else {
  bind.setInt(value.getValue());
 }
}

代码示例来源:origin: benas/random-beans

@Override
  public LocalDate getRandomValue() {
    Year randomYear = yearRandomizer.getRandomValue();
    Month randomMonth = monthRandomizer.getRandomValue();
    int randomDay = dayRandomizer.getRandomValue();
    return LocalDate.of(randomYear.getValue(), randomMonth.getValue(), randomDay);
  }
}

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

@SuppressWarnings("rawtypes")
 @Test
 public void testTimestampParsing() throws ParseException {
  JSONObject parsed = parser.parse(fireeyeMessage.getBytes()).get(0);
  JSONParser parser = new JSONParser();
  Map json = (Map) parser.parse(parsed.toJSONString());
  long expectedTimestamp = ZonedDateTime.of(Year.now(ZoneOffset.UTC).getValue(), 3, 19, 5, 24, 39, 0, ZoneOffset.UTC).toInstant().toEpochMilli();
  Assert.assertEquals(expectedTimestamp, json.get("timestamp"));
 }
}

代码示例来源:origin: benas/random-beans

@Override
  public YearMonth getRandomValue() {
    Year randomYear = yearRandomizer.getRandomValue();
    Month randomMonth = monthRandomizer.getRandomValue();
    return YearMonth.of(randomYear.getValue(), randomMonth.getValue());
  }
}

代码示例来源:origin: benas/random-beans

@Override
  public Period getRandomValue() {
    Year randomYear = yearRandomizer.getRandomValue();
    Month randomMonth = monthRandomizer.getRandomValue();
    int randomDay = dayRandomizer.getRandomValue();
    return Period.of(randomYear.getValue(), randomMonth.getValue(), randomDay);
  }
}

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

@Test
public void testParseOtherLine() throws Exception {
  
  //Set up parser, parse message
  GrokWebSphereParser parser = new GrokWebSphereParser();
  parser.configure(parserConfig);
  String testString = "<134>Apr 15 17:17:34 SAGPXMLQA333 [0x8240001c][audit][info] trans(191): (admin:default:system:*): "
      + "ntp-service 'NTP Service' - Operational state down";
  Optional<MessageParserResult<JSONObject>> resultOptional = parser.parseOptionalResult(testString.getBytes());
  Assert.assertNotNull(resultOptional);
  Assert.assertTrue(resultOptional.isPresent());
  List<JSONObject> result = resultOptional.get().getMessages();
  JSONObject parsedJSON = result.get(0);
  long expectedTimestamp = ZonedDateTime.of(Year.now(UTC).getValue(), 4, 15, 17, 17, 34, 0, UTC).toInstant().toEpochMilli();
  
  //Compare fields
  assertEquals(134, parsedJSON.get("priority"));
  assertEquals(expectedTimestamp, parsedJSON.get("timestamp"));
  assertEquals("SAGPXMLQA333", parsedJSON.get("hostname"));
  assertEquals("0x8240001c", parsedJSON.get("event_code"));
  assertEquals("audit", parsedJSON.get("event_type"));
  assertEquals("info", parsedJSON.get("severity"));
  assertEquals("trans", parsedJSON.get("process"));
  assertEquals("(admin:default:system:*): ntp-service 'NTP Service' - Operational state down", parsedJSON.get("message"));
}

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

@Test
public void testParseRBMLine() throws Exception {
  
  //Set up parser, parse message
  GrokWebSphereParser parser = new GrokWebSphereParser();
  parser.configure(parserConfig);
  String testString = "<131>Apr 15 17:36:35 ROBXML3QRS [0x80800018][auth][error] rbm(RBM-Settings): "
      + "trans(3502888135)[request] gtid(3502888135): RBM: Resource access denied.";
  Optional<MessageParserResult<JSONObject>> resultOptional = parser.parseOptionalResult(testString.getBytes());
  Assert.assertNotNull(resultOptional);
  Assert.assertTrue(resultOptional.isPresent());
  List<JSONObject> result = resultOptional.get().getMessages();
  JSONObject parsedJSON = result.get(0);
  long expectedTimestamp = ZonedDateTime.of(Year.now(UTC).getValue(), 4, 15, 17, 36, 35, 0, UTC).toInstant().toEpochMilli();
  
  //Compare fields
  assertEquals(131, parsedJSON.get("priority"));
  assertEquals(expectedTimestamp, parsedJSON.get("timestamp"));
  assertEquals("ROBXML3QRS", parsedJSON.get("hostname"));
  assertEquals("0x80800018", parsedJSON.get("event_code"));
  assertEquals("auth", parsedJSON.get("event_type"));
  assertEquals("error", parsedJSON.get("severity"));
  assertEquals("rbm", parsedJSON.get("process"));
  assertEquals("trans(3502888135)[request] gtid(3502888135): RBM: Resource access denied.", parsedJSON.get("message"));
}

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