java.time.ZonedDateTime.getDayOfMonth()方法的使用及代码示例

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

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

ZonedDateTime.getDayOfMonth介绍

[英]Gets the day-of-month field.

This method returns the primitive int value for the day-of-month.
[中]获取月日字段。
此方法返回月日的原始int值。

代码示例

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

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

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

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

代码示例来源:origin: blynkkk/blynk-server

private ZonedDateTime adjustToStartDate(ZonedDateTime zonedStartAt, ZonedDateTime zonedNow, ZoneId zoneId) {
  if (durationType == ReportDurationType.CUSTOM) {
    ZonedDateTime zonedStartDate = getZonedFromTs(startTs, zoneId).with(LocalTime.MIN);
    if (zonedStartDate.isAfter(zonedNow)) {
      zonedStartAt = zonedStartAt
          .withDayOfMonth(zonedStartDate.getDayOfMonth())
          .withMonth(zonedStartDate.getMonthValue())
          .withYear(zonedStartDate.getYear());
    }
  }
  return zonedStartAt;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public int getDayOfMonth() {
  return dt.getDayOfMonth();
}

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

private void assertTimestamp(String c4) {
  // '2014-09-08 17:51:04.777'
  // MySQL container is in UTC and the test time is during summer time period
  ZonedDateTime expectedTimestamp = ZonedDateTime.ofInstant(
      LocalDateTime.parse("2014-09-08T17:51:04.780").atZone(ZoneId.of("US/Samoa")).toInstant(),
      ZoneId.systemDefault());
  ZoneId defaultZoneId = ZoneId.systemDefault();
  ZonedDateTime c4DateTime = ZonedDateTime.parse(c4, ZonedTimestamp.FORMATTER).withZoneSameInstant(defaultZoneId);
  assertThat(c4DateTime.getYear()).isEqualTo(expectedTimestamp.getYear());
  assertThat(c4DateTime.getMonth()).isEqualTo(expectedTimestamp.getMonth());
  assertThat(c4DateTime.getDayOfMonth()).isEqualTo(expectedTimestamp.getDayOfMonth());
  assertThat(c4DateTime.getHour()).isEqualTo(expectedTimestamp.getHour());
  assertThat(c4DateTime.getMinute()).isEqualTo(expectedTimestamp.getMinute());
  assertThat(c4DateTime.getSecond()).isEqualTo(expectedTimestamp.getSecond());
  assertThat(c4DateTime.getNano()).isEqualTo(expectedTimestamp.getNano());
  // We're running the connector in the same timezone as the server, so the timezone in the timestamp
  // should match our current offset ...
  LocalDateTime expectedLocalDateTime = LocalDateTime.parse("2014-09-08T17:51:04.780");
  ZoneOffset expectedOffset = defaultZoneId.getRules().getOffset(expectedLocalDateTime);
  assertThat(c4DateTime.getOffset()).isEqualTo(expectedOffset);
}

代码示例来源:origin: rakam-io/rakam

int day = dateTime.getDayOfMonth();
String weekDay = dateTime.getDayOfWeek().getDisplayName(SHORT, US);
DataSource dataSource = new ByteArrayDataSource(bytes, "image/png");

代码示例来源:origin: HubSpot/jinjava

@SuppressWarnings("deprecation")
@Override
public int getDay() {
 return date.getDayOfMonth();
}

代码示例来源:origin: org.vertexium/vertexium-cypher

@Override
  protected Object invokeZonedDateTime(VertexiumCypherQueryContext ctx, ZonedDateTime date, ExpressionScope scope) {
    return date.getDayOfMonth();
  }
}

代码示例来源:origin: mulesoft/mule

private void assertTimeZoneDate(ZonedDateTime openingDate) {
 assertEquals(openingDate.getYear(), YEAR);
 assertEquals(openingDate.getMonthValue(), MONTH);
 assertEquals(openingDate.getDayOfMonth(), DAY);
}

代码示例来源:origin: com.squarespace.cldr/cldr-runtime

/**
 * Numeric day of week in month, as in "2nd Wednesday in July".
 */
void formatDayOfWeekInMonth(StringBuilder b, ZonedDateTime d, int width) {
 int day = ((d.getDayOfMonth() - 1) / 7) + 1;
 b.append(day);
}

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

@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final ZonedDateTime zonedDateTime) {
  output.writeInt(zonedDateTime.getYear());
  output.writeInt(zonedDateTime.getMonthValue());
  output.writeInt(zonedDateTime.getDayOfMonth());
  output.writeInt(zonedDateTime.getHour());
  output.writeInt(zonedDateTime.getMinute());
  output.writeInt(zonedDateTime.getSecond());
  output.writeInt(zonedDateTime.getNano());
  output.writeString(zonedDateTime.getZone().getId());
}

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

public BigDecimal day(ZonedDateTime date) {
  try {
    return BigDecimal.valueOf(date.getDayOfMonth());
  } catch (Exception e) {
    String message = String.format("day(%s)", date);
    logError(message, e);
    return null;
  }
}

代码示例来源:origin: com.conveyal/r5

/**
 * Creates LocalDateTime based on seconds from midnight for time and date from requested ZonedDateTime
 *
 * @param time in seconds from midnight
 * @param fromTimeDateZD
 * @return
 */
private ZonedDateTime createTime(int time, ZonedDateTime fromTimeDateZD) {
  //TODO: check timezones correct time etc. this is untested
  LocalDateTime localDateTime = LocalDateTime.of(fromTimeDateZD.getYear(), fromTimeDateZD.getMonth(), fromTimeDateZD.getDayOfMonth(), 0,0);
  return localDateTime.plusSeconds(time).atZone(fromTimeDateZD.getZone());
}

代码示例来源:origin: conveyal/r5

/**
 * Creates LocalDateTime based on seconds from midnight for time and date from requested ZonedDateTime
 *
 * @param time in seconds from midnight
 * @param fromTimeDateZD
 * @return
 */
private ZonedDateTime createTime(int time, ZonedDateTime fromTimeDateZD) {
  //TODO: check timezones correct time etc. this is untested
  LocalDateTime localDateTime = LocalDateTime.of(fromTimeDateZD.getYear(), fromTimeDateZD.getMonth(), fromTimeDateZD.getDayOfMonth(), 0,0);
  return localDateTime.plusSeconds(time).atZone(fromTimeDateZD.getZone());
}

代码示例来源:origin: apache/james-project

@Test
void dayOfWeekShouldBeParsedWhenOneDigit() {
  ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
  assertThat(dateTime.getDayOfMonth()).isEqualTo(3);
}

代码示例来源:origin: org.apache.james/james-server-util-java8

@Test
public void dayOfWeekShouldBeParsedWhenOneDigit() {
  ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
  assertThat(dateTime.getDayOfMonth()).isEqualTo(3);
}

代码示例来源:origin: dlemmermann/CalendarFX

static DateValue zonedDateTimeToDateValue(ZonedDateTime dt) {
  return new DateTimeValueImpl(
      dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(),
      dt.getHour(), dt.getMinute(), dt.getSecond());
}

代码示例来源:origin: org.mule.runtime/mule-module-extensions-spring-support

private void assertTimeZoneDate(ZonedDateTime openingDate) {
 assertEquals(openingDate.getYear(), YEAR);
 assertEquals(openingDate.getMonthValue(), MONTH);
 assertEquals(openingDate.getDayOfMonth(), DAY);
}

代码示例来源:origin: com.cronutils/cron-utils

private ExecutionTimeResult getNextPotentialDayOfMonth(final ZonedDateTime date,
                            final int lowestHour,
                            final int lowestMinute,
                            final int lowestSecond,
                            final TimeNode node) {
  final NearestValue nearestValue = node.getNextValue(date.getDayOfMonth(), 0);
  if (nearestValue.getShifts() > 0) {
    return new ExecutionTimeResult(date.truncatedTo(DAYS).withDayOfMonth(1).plusMonths(nearestValue.getShifts()), false);
  }
  return new ExecutionTimeResult(date.truncatedTo(SECONDS).withDayOfMonth(nearestValue.getValue())
      .with(LocalTime.of(lowestHour, lowestMinute, lowestSecond)), false);
}

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

@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final ZonedDateTime zonedDateTime) {
  output.writeInt(zonedDateTime.getYear());
  output.writeInt(zonedDateTime.getMonthValue());
  output.writeInt(zonedDateTime.getDayOfMonth());
  output.writeInt(zonedDateTime.getHour());
  output.writeInt(zonedDateTime.getMinute());
  output.writeInt(zonedDateTime.getSecond());
  output.writeInt(zonedDateTime.getNano());
  output.writeString(zonedDateTime.getZone().getId());
}

相关文章

ZonedDateTime类方法