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

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

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

YearMonth.getMonthValue介绍

[英]Gets the month-of-year field from 1 to 12.

This method returns the month as an int from 1 to 12. Application code is frequently clearer if the enum Monthis used by calling #getMonth().
[中]获取从1到12的月份字段。
此方法将月份返回为1到12之间的整数。如果通过调用#getMonth()来使用enum Monthis,则应用程序代码通常更清晰。

代码示例

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

  1. protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
  2. SerializerProvider provider) throws IOException
  3. {
  4. g.writeNumber(value.getYear());
  5. g.writeNumber(value.getMonthValue());
  6. }

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

  1. protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
  2. SerializerProvider provider) throws IOException
  3. {
  4. g.writeNumber(value.getYear());
  5. g.writeNumber(value.getMonthValue());
  6. }

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

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

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

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

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

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

代码示例来源:origin: net.nemerosa.ontrack/ontrack-json

  1. @Override
  2. public void serialize(YearMonth value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
  3. Map<String, Integer> map = new LinkedHashMap<>();
  4. map.put("year", value.getYear());
  5. map.put("month", value.getMonthValue());
  6. provider.defaultSerializeValue(
  7. map,
  8. jgen
  9. );
  10. }

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

  1. DateTimeFormatter formatter = new DateTimeFormatterBuilder()
  2. .appendPattern("MMMM yyyy")
  3. .toFormatter(Locale.US);
  4. TemporalAccessor ta = formatter.parse("October 2015");
  5. YearMonth ym = YearMonth.from(ta);
  6. LocalDateTime dt = LocalDateTime.of(ym.getYear(), ym.getMonthValue(),
  7. 1, 0, 0, 0);
  8. Instant instant = Instant.from(dt.atZone(ZoneId.systemDefault()));
  9. Date d = Date.from(instant);

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

  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: org.opensingular/singular-form-wicket

  1. @Override
  2. public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) {
  3. if ((model != null) && (model.getObject() != null)) {
  4. SInstance instance = model.getObject();
  5. if (instance.getValue() instanceof YearMonth) {
  6. YearMonth ym = (YearMonth) instance.getValue();
  7. return String.format("%02d/%04d", ym.getMonthValue(), ym.getYear());
  8. }
  9. }
  10. return StringUtils.EMPTY;
  11. }
  12. }

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

  1. @Override
  2. public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) {
  3. if ((model != null) && (model.getObject() != null)) {
  4. SInstance instancia = model.getObject();
  5. if (instancia.getValue() instanceof YearMonth) {
  6. YearMonth ym = (YearMonth) instancia.getValue();
  7. return String.format("%02d/%04d", ym.getMonthValue(), ym.getYear());
  8. }
  9. }
  10. return StringUtils.EMPTY;
  11. }
  12. }

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

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

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

  1. @Override
  2. public void write(ByteWriter writer, YearMonth yearMonth) {
  3. Preconditions.checkArgument(yearMonth != null, "null yearMonth");
  4. Preconditions.checkArgument(writer != null);
  5. LongEncoder.write(writer, yearMonth.getYear());
  6. LongEncoder.write(writer, yearMonth.getMonthValue());
  7. }

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

  1. public Integer getMes() {
  2. if (isEmptyOfData()) {
  3. return null;
  4. }
  5. return getValue().getMonthValue();
  6. }

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

  1. public Integer getMes() {
  2. if (isEmptyOfData()) {
  3. return null;
  4. }
  5. return getValue().getMonthValue();
  6. }

代码示例来源:origin: org.jsimpledb/jsimpledb-coreapi

  1. @Override
  2. public void write(ByteWriter writer, YearMonth yearMonth) {
  3. Preconditions.checkArgument(yearMonth != null, "null yearMonth");
  4. Preconditions.checkArgument(writer != null);
  5. LongEncoder.write(writer, yearMonth.getYear());
  6. LongEncoder.write(writer, yearMonth.getMonthValue());
  7. }

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

  1. protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
  2. SerializerProvider provider) throws IOException
  3. {
  4. g.writeNumber(value.getYear());
  5. g.writeNumber(value.getMonthValue());
  6. }

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

  1. protected void _serializeAsArrayContents(YearMonth value, JsonGenerator g,
  2. SerializerProvider provider) throws IOException
  3. {
  4. g.writeNumber(value.getYear());
  5. g.writeNumber(value.getMonthValue());
  6. }

代码示例来源:origin: com.esotericsoftware/kryo

  1. public void write (Kryo kryo, Output out, YearMonth obj) {
  2. out.writeInt(obj.getYear(), true);
  3. out.writeByte(obj.getMonthValue());
  4. }

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

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

相关文章