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

x33g5p2x  于2022-02-05 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(195)

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

YearMonth.of介绍

[英]Obtains an instance of YearMonth from a year and month.
[中]

代码示例

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

  1. @Override
  2. public YearMonth convertToEntityAttribute(Integer dbData) {
  3. return YearMonth.of(dbData / 100, dbData % 100);
  4. }
  5. }

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

  1. @Override
  2. public YearMonth readObject(ObjectInput input) throws IOException, ClassNotFoundException {
  3. int year = input.readInt();
  4. Month month = DefaultExternalizer.MONTH.cast(Month.class).readObject(input);
  5. return YearMonth.of(year, month);
  6. }

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

  1. @Override
  2. protected void afterEntityManagerFactoryBuilt() {
  3. doInJPA( this::entityManagerFactory, entityManager -> {
  4. employee.id = 1L;
  5. employee.username = "user@acme.com";
  6. employee.nextVacation = YearMonth.of( 2018, 12 );
  7. entityManager.persist( employee );
  8. } );
  9. }

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

  1. @Test
  2. public void test() {
  3. doInJPA( this::entityManagerFactory, entityManager -> {
  4. Employee employee = entityManager.find(Employee.class, 1L);
  5. assertEquals( YearMonth.of( 2018, 12 ), employee.nextVacation );
  6. } );
  7. }

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

  1. "Expected array to end");
  2. return YearMonth.of(year, month);

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

  1. "Expected array to end");
  2. return YearMonth.of(year, month);

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

  1. @Override
  2. protected YearMonth readValue(final ByteBuf buffer, final GraphBinaryReader context) throws SerializationException {
  3. return YearMonth.of(buffer.readInt(), buffer.readByte());
  4. }

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

  1. @Override
  2. public <I extends InputShim> YearMonth read(final KryoShim<I, ?> kryo, final I input, final Class<YearMonth> clazz) {
  3. return YearMonth.of(input.readInt(), input.readInt());
  4. }
  5. }

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

  1. protected YearMonth fromLocalDate(LocalDate localDate) {
  2. return YearMonth.of(localDate.getYear(), localDate.getMonth());
  3. }

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

  1. @Override public YearMonth generate(SourceOfRandomness random, GenerationStatus status) {
  2. long generated = random.nextLong(
  3. min.getYear() * 12L + min.getMonthValue() - 1,
  4. max.getYear() * 12L + max.getMonthValue() - 1);
  5. return YearMonth.of(
  6. (int) (generated / 12),
  7. (int) Math.abs(generated % 12) + 1);
  8. }
  9. }

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

  1. @Override
  2. public YearMonth getRandomValue() {
  3. Year randomYear = yearRandomizer.getRandomValue();
  4. Month randomMonth = monthRandomizer.getRandomValue();
  5. return YearMonth.of(randomYear.getValue(), randomMonth.getValue());
  6. }
  7. }

代码示例来源:origin: vladmihalcea/high-performance-java-persistence

  1. @Override
  2. public YearMonth convertToEntityAttribute(Integer dbData) {
  3. int year = dbData / 100;
  4. int month = dbData % 100;
  5. return YearMonth.of(year, month);
  6. }
  7. }

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

  1. addExtendedEntry(new Short("100"), "Short", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
  2. addExtendedEntry(Year.of(2016), "Year", "The following example is of the `Year` \"2016\".", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
  3. addExtendedEntry(YearMonth.of(2016, 6), "YearMonth", "The following example is a `YearMonth` of \"June 2016\"", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
  4. addExtendedEntry(ZonedDateTime.of(2016, 12, 23, 12, 12, 24, 36, ZoneId.of("GMT+2")), "ZonedDateTime", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
  5. addExtendedEntry(ZoneOffset.ofHoursMinutesSeconds(3, 6, 9), "ZoneOffset", "The following example is a `ZoneOffset` of three hours, six minutes, and nine seconds.", Compatibilities.UNTYPED_GRAPHSON.matchToArray());

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

  1. public void createFutureFromOptionContractSpec() {
  2. assertThatThrownBy(() -> OPTION_CONTRACT.createFuture(YearMonth.of(2015, 6), EtdVariant.MONTHLY))
  3. .isInstanceOf(IllegalStateException.class)
  4. .hasMessage("Cannot create an EtdFutureSecurity from a contract specification of type 'Option'");
  5. }

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

  1. public void test_optionIdUnderlying_monthly() {
  2. SecurityId test = EtdIdUtils.optionId(
  3. ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY, 0, PutCall.PUT, 12.34, YearMonth.of(2017, 9));
  4. assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706-P12.34-U201709"));
  5. }

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

  1. public void test_optionIdUnderlying_monthlySameMonth() {
  2. SecurityId test = EtdIdUtils.optionId(
  3. ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), MONTHLY, 0, PutCall.PUT, 12.34, YearMonth.of(2017, 6));
  4. assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "O-ECAG-FGBS-201706-P12.34"));
  5. }

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

  1. public void test_futureId_flex() {
  2. SecurityId test = EtdIdUtils.futureId(
  3. ExchangeIds.ECAG, FGBS, YearMonth.of(2017, 6), EtdVariant.ofFlexFuture(26, EtdSettlementType.DERIVATIVE));
  4. assertEquals(test.getStandardId(), StandardId.of("OG-ETD", "F-ECAG-FGBS-20170626D"));
  5. }

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

  1. static EtdOptionSecurity sut2() {
  2. return EtdOptionSecurity.builder()
  3. .info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10)))
  4. .contractSpecId(EtdContractSpecId.of("test", "234"))
  5. .expiry(YearMonth.of(2017, 9))
  6. .variant(EtdVariant.ofWeekly(2))
  7. .version(4)
  8. .putCall(PutCall.CALL)
  9. .strikePrice(3)
  10. .underlyingExpiryMonth(YearMonth.of(2017, 12))
  11. .build();
  12. }

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

  1. static EtdFutureSecurity sut() {
  2. return EtdFutureSecurity.builder()
  3. .info(SecurityInfo.of(SecurityId.of("A", "B"), SecurityPriceInfo.of(Currency.GBP, 100)))
  4. .contractSpecId(EtdContractSpecId.of("test", "123"))
  5. .expiry(YearMonth.of(2017, 6))
  6. .build();
  7. }

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

  1. static EtdFutureSecurity sut2() {
  2. return EtdFutureSecurity.builder()
  3. .info(SecurityInfo.of(SecurityId.of("B", "C"), SecurityPriceInfo.of(Currency.EUR, 10)))
  4. .contractSpecId(EtdContractSpecId.of("test", "234"))
  5. .expiry(YearMonth.of(2017, 9))
  6. .variant(EtdVariant.ofWeekly(2))
  7. .build();
  8. }

相关文章