gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-17 21:26:40 29 4
gpt4 key购买 nike

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

ZonedDateTime.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 datetime are in the same year and 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 and month, false otherwise
 */
private static boolean haveSameYearAndMonth(ZonedDateTime actual, ZonedDateTime other) {
 return haveSameYear(actual, other) && actual.getMonth() == other.getMonth();
}

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

/**
 * Returns true if both datetime are in the same year and 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 and month, false otherwise
 */
private static boolean haveSameYearAndMonth(ZonedDateTime actual, ZonedDateTime other) {
 return haveSameYear(actual, other) && actual.getMonth() == other.getMonth();
}

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

public Month getMonth() {
  return dt.getMonth();
}

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

String month = dateTime.getMonth().getDisplayName(SHORT, US);
int day = dateTime.getDayOfMonth();
String weekDay = dateTime.getDayOfWeek().getDisplayName(SHORT, US);

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

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

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

/**
 * Returns true if both datetime are in the same year and 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 and month, false otherwise
 */
private static boolean haveSameYearAndMonth(ZonedDateTime actual, ZonedDateTime other) {
 return haveSameYear(actual, other) && actual.getMonth() == other.getMonth();
}

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

public Double month(ZonedDateTime dateTime) {
  try {
    return Double.valueOf(dateTime.getMonth().getValue());
  } catch (Exception e) {
    String message = String.format("month(%s)", dateTime);
    logError(message, e);
    return null;
  }
}

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

public BigDecimal month(ZonedDateTime dateTime) {
  try {
    return BigDecimal.valueOf(dateTime.getMonth().getValue());
  } catch (Exception e) {
    String message = String.format("month(%s)", dateTime);
    logError(message, e);
    return null;
  }
}

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

public BigDecimal month(ZonedDateTime dateTime) {
  try {
    return BigDecimal.valueOf(dateTime.getMonth().getValue());
  } catch (Exception e) {
    String message = String.format("month(%s)", dateTime);
    logError(message, e);
    return null;
  }
}

代码示例来源:origin: goldmansachs/jdmn

public Double month(ZonedDateTime dateTime) {
  try {
    return Double.valueOf(dateTime.getMonth().getValue());
  } catch (Exception e) {
    String message = String.format("month(%s)", dateTime);
    logError(message, e);
    return null;
  }
}

代码示例来源:origin: goldmansachs/jdmn

public BigDecimal month(ZonedDateTime dateTime) {
  try {
    return BigDecimal.valueOf(dateTime.getMonth().getValue());
  } catch (Exception e) {
    String message = String.format("month(%s)", dateTime);
    logError(message, e);
    return null;
  }
}

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

@Override
  public YearMonth convert(Date in, Context context) throws Exception {
    if (in == null) return null;
    ZonedDateTime zonedDateTime = in.toInstant().atZone(zoneId);
    return YearMonth.of(zonedDateTime.getYear(), zonedDateTime.getMonth());
  }
}

代码示例来源:origin: kittylyst/javanut6-examples

public Duration getMeetingDurationInMonth(Month month) {
  return meetings.values().stream()
      .filter(m -> month.equals(m.getStart().getMonth()))
      .map(m -> Duration.between(m.getStart(), m.getEnd()))
      .reduce(Duration.ofMinutes(0), (a, b) -> a.plus(b));
}

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

ZoneId zoneId = ZoneId.of( "America/Montreal" );  // Or 'ZoneOffset.UTC'.
ZonedDateTime now = ZonedDateTime.now( zoneId );
Month month = now.getMonth(); 
int monthNumber = month.getValue(); // Answer to the Question.
String monthName = month.getDisplayName( TextStyle.FULL , Locale.CANADA_FRENCH );

代码示例来源: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: com.cronutils/cron-utils

private ZonedDateTime toEndOfPreviousMonth(final ZonedDateTime datetime) {
  final ZonedDateTime previousMonth = datetime.minusMonths(1).with(lastDayOfMonth());
  final int highestHour = hours.getValues().get(hours.getValues().size() - 1);
  final int highestMinute = minutes.getValues().get(minutes.getValues().size() - 1);
  final int highestSecond = seconds.getValues().get(seconds.getValues().size() - 1);
  return ZonedDateTime
      .of(previousMonth.getYear(), previousMonth.getMonth().getValue(), previousMonth.getDayOfMonth(), highestHour, highestMinute, highestSecond, 0,
          previousMonth.getZone());
}

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

@Test
void monthOfYearShouldBeParsed() {
  ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
  assertThat(dateTime.getMonth()).isEqualTo(Month.JUNE);
}

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

@Test
public void monthOfYearShouldBeParsed() {
  ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
  assertThat(dateTime.getMonth()).isEqualTo(Month.JUNE);
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com