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

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

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

OffsetDateTime.getMonth介绍

[英]Gets the month-of-year field using the Month enum.

This method returns the enum Month for the month. This avoids confusion as to what int values mean. If you need access to the primitive int value then the enum provides the Month#getValue().
[中]使用月份枚举获取“月份”字段。
此方法返回当月的枚举月份。这避免了对int值的含义的混淆。如果需要访问原语int值,则枚举提供月#getValue()。

代码示例

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

/**
 * Returns true if both OffsetDateTime are in the same year and month, false otherwise.
 *
 * @param actual the actual OffsetDateTime. expected not be null
 * @param other the other OffsetDateTime. expected not be null
 * @return true if both OffsetDateTime are in the same year and month, false otherwise
 */
private static boolean haveSameYearAndMonth(OffsetDateTime actual, OffsetDateTime other) {
 return haveSameYear(actual, other) && actual.getMonth() == other.getMonth();
}

代码示例来源:origin: joel-costigliola/assertj-core

/**
 * Returns true if both OffsetDateTime are in the same year and month, false otherwise.
 *
 * @param actual the actual OffsetDateTime. expected not be null
 * @param other the other OffsetDateTime. expected not be null
 * @return true if both OffsetDateTime are in the same year and month, false otherwise
 */
private static boolean haveSameYearAndMonth(OffsetDateTime actual, OffsetDateTime other) {
 return haveSameYear(actual, other) && actual.getMonth() == other.getMonth();
}

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

assertThat(c4DateTime.getMonth()).isEqualTo(Month.JANUARY);
assertThat(c4DateTime.getDayOfMonth()).isEqualTo(1);

代码示例来源:origin: Netflix/iceberg

static String humanDay(int dayOrdinal) {
 OffsetDateTime day = EPOCH.plusDays(dayOrdinal);
 return String.format("%04d-%02d-%02d",
   day.getYear(), day.getMonth().getValue(), day.getDayOfMonth());
}

代码示例来源:origin: Netflix/iceberg

@Override
 public String read(String reuse) {
  OffsetDateTime day = EPOCH.plusDays(column.nextInteger());
  return format("%04d-%02d-%02d", day.getYear(), day.getMonth().getValue(), day.getDayOfMonth());
 }
}

代码示例来源:origin: Netflix/iceberg

static String humanHour(int hourOrdinal) {
 OffsetDateTime time = EPOCH.plusHours(hourOrdinal);
 return String.format("%04d-%02d-%02d-%02d",
   time.getYear(), time.getMonth().getValue(), time.getDayOfMonth(), time.getHour());
}

代码示例来源:origin: rocks.xmpp/xmpp-extensions-common

/**
 * Creates a date value.
 *
 * @param date The date value.
 */
private Value(OffsetDateTime date) {
  XMLGregorianCalendar xmlGregorianCalendar;
  try {
    xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
    xmlGregorianCalendar.setYear(date.getYear());
    xmlGregorianCalendar.setMonth(date.getMonth().getValue());
    xmlGregorianCalendar.setDay(date.getDayOfMonth());
    xmlGregorianCalendar.setTime(date.getHour(), date.getMinute(), date.getSecond()); // date.get(ChronoField.MILLI_OF_SECOND)
    xmlGregorianCalendar.setTimezone(date.getOffset().getTotalSeconds() / 60);
  } catch (DatatypeConfigurationException e) {
    xmlGregorianCalendar = null;
  }
  this.value = xmlGregorianCalendar;
}

代码示例来源:origin: io.debezium/debezium-connector-mysql

assertThat(c4DateTime.getMonth()).isEqualTo(Month.JANUARY);
assertThat(c4DateTime.getDayOfMonth()).isEqualTo(1);

相关文章