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

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

本文整理了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

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

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

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

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

  1. /**
  2. * Creates a new Carbon instance from the provided offset date time object.
  3. *
  4. * @param offsetDateTime The offset date time that the Carbon instance should be created from.
  5. * @return a Carbon instance with the provided date and time.
  6. */
  7. public static Carbon createFromOffsetDateTime(OffsetDateTime offsetDateTime) {
  8. return Carbon.create(
  9. offsetDateTime.getYear(),
  10. offsetDateTime.getMonthValue(),
  11. offsetDateTime.getDayOfMonth(),
  12. offsetDateTime.getHour(),
  13. offsetDateTime.getMinute(),
  14. offsetDateTime.getSecond()
  15. );
  16. }

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

  1. @Override
  2. public final void serialize(Writer writer, OffsetDateTime datetime) throws IOException {
  3. super.serialize(writer, datetime);
  4. OutputStream stream = writer.stream;
  5. if (!(datetime.getOffset().equals(ZoneOffset.UTC))) {
  6. stream.write(TagString);
  7. ValueWriter.write(stream, datetime.toString());
  8. }
  9. else {
  10. int year = datetime.getYear();
  11. if (year > 9999 || year < 1) {
  12. stream.write(TagString);
  13. ValueWriter.write(stream, datetime.toString());
  14. }
  15. else {
  16. ValueWriter.writeDate(stream, year, datetime.getMonthValue(), datetime.getDayOfMonth());
  17. ValueWriter.writeTime(stream, datetime.getHour(), datetime.getMinute(), datetime.getSecond(), 0, false, true);
  18. ValueWriter.writeNano(stream, datetime.getNano());
  19. stream.write(TagUTC);
  20. }
  21. }
  22. }
  23. }

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

  1. @Override
  2. public final void serialize(Writer writer, OffsetDateTime datetime) throws IOException {
  3. super.serialize(writer, datetime);
  4. OutputStream stream = writer.stream;
  5. if (!(datetime.getOffset().equals(ZoneOffset.UTC))) {
  6. stream.write(TagString);
  7. ValueWriter.write(stream, datetime.toString());
  8. }
  9. else {
  10. int year = datetime.getYear();
  11. if (year > 9999 || year < 1) {
  12. stream.write(TagString);
  13. ValueWriter.write(stream, datetime.toString());
  14. }
  15. else {
  16. ValueWriter.writeDate(stream, year, datetime.getMonthValue(), datetime.getDayOfMonth());
  17. ValueWriter.writeTime(stream, datetime.getHour(), datetime.getMinute(), datetime.getSecond(), 0, false, true);
  18. ValueWriter.writeNano(stream, datetime.getNano());
  19. stream.write(TagUTC);
  20. }
  21. }
  22. }
  23. }

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

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

相关文章