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

x33g5p2x  于2022-01-25 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(99)

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

OffsetDateTime.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: lukstei/trading-backtest

private static String toYahooQueryDate(Instant instant, String names) {
    OffsetDateTime time = instant.atOffset(ZoneOffset.UTC);
    String[] strings = names.split("");
    return format("%s=%d&%s=%d&%s=%d", strings[0], time.getMonthValue() - 1, strings[1], time.getDayOfMonth(), strings[2], time.getYear());
  }
}

代码示例来源:origin: kiegroup/optaweb-employee-rostering

public static LocalDate toLocalDate(OffsetDateTime time) {
  return LocalDate.of(time.getYear(), time.getMonthValue(), time.getDayOfMonth());
}

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

/**
 * Creates a new Carbon instance from the provided offset date time object.
 *
 * @param offsetDateTime The offset date time that the Carbon instance should be created from.
 * @return a Carbon instance with the provided date and time.
 */
public static Carbon createFromOffsetDateTime(OffsetDateTime offsetDateTime) {
  return Carbon.create(
    offsetDateTime.getYear(),
    offsetDateTime.getMonthValue(),
    offsetDateTime.getDayOfMonth(),
    offsetDateTime.getHour(),
    offsetDateTime.getMinute(),
    offsetDateTime.getSecond()
  );
}

代码示例来源:origin: hprose/hprose-java

@Override
  public final void serialize(Writer writer, OffsetDateTime datetime) throws IOException {
    super.serialize(writer, datetime);
    OutputStream stream = writer.stream;
    if (!(datetime.getOffset().equals(ZoneOffset.UTC))) {
      stream.write(TagString);
      ValueWriter.write(stream, datetime.toString());
    }
    else {
      int year = datetime.getYear();
      if (year > 9999 || year < 1) {
        stream.write(TagString);
        ValueWriter.write(stream, datetime.toString());
      }
      else {
        ValueWriter.writeDate(stream, year, datetime.getMonthValue(), datetime.getDayOfMonth());
        ValueWriter.writeTime(stream, datetime.getHour(), datetime.getMinute(), datetime.getSecond(), 0, false, true);
        ValueWriter.writeNano(stream, datetime.getNano());
        stream.write(TagUTC);
      }
    }
  }
}

代码示例来源:origin: org.hprose/hprose-java

@Override
  public final void serialize(Writer writer, OffsetDateTime datetime) throws IOException {
    super.serialize(writer, datetime);
    OutputStream stream = writer.stream;
    if (!(datetime.getOffset().equals(ZoneOffset.UTC))) {
      stream.write(TagString);
      ValueWriter.write(stream, datetime.toString());
    }
    else {
      int year = datetime.getYear();
      if (year > 9999 || year < 1) {
        stream.write(TagString);
        ValueWriter.write(stream, datetime.toString());
      }
      else {
        ValueWriter.writeDate(stream, year, datetime.getMonthValue(), datetime.getDayOfMonth());
        ValueWriter.writeTime(stream, datetime.getHour(), datetime.getMinute(), datetime.getSecond(), 0, false, true);
        ValueWriter.writeNano(stream, datetime.getNano());
        stream.write(TagUTC);
      }
    }
  }
}

代码示例来源:origin: ngs-doo/dsl-json

NumberConverter.write4(year, buf, pos + 1);
buf[pos + 5] = '-';
NumberConverter.write2(value.getMonthValue(), buf, pos + 6);
buf[pos + 8] = '-';
NumberConverter.write2(value.getDayOfMonth(), buf, pos + 9);

相关文章