org.threeten.bp.LocalDateTime.withDayOfMonth()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(160)

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

LocalDateTime.withDayOfMonth介绍

[英]Returns a copy of this LocalDateTime with the day-of-month altered. If the resulting LocalDateTime is invalid, an exception is thrown. The time does not affect the calculation and will be the same in the result.

This instance is immutable and unaffected by this method call.
[中]返回更改了月份日期的LocalDateTime的副本。如果生成的LocalDateTime无效,将引发异常。时间不影响计算,结果相同。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Returns a copy of this {@code OffsetDateTime} with the day-of-month altered.
 * If the resulting {@code OffsetDateTime} is invalid, an exception is thrown.
 * The offset does not affect the calculation and will be the same in the result.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param dayOfMonth  the day-of-month to set in the result, from 1 to 28-31
 * @return an {@code OffsetDateTime} based on this date-time with the requested day, not null
 * @throws DateTimeException if the day-of-month value is invalid
 * @throws DateTimeException if the day-of-month is invalid for the month-year
 */
public OffsetDateTime withDayOfMonth(int dayOfMonth) {
  return with(dateTime.withDayOfMonth(dayOfMonth), offset);
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Returns a copy of this {@code OffsetDateTime} with the day-of-month altered.
 * If the resulting {@code OffsetDateTime} is invalid, an exception is thrown.
 * The offset does not affect the calculation and will be the same in the result.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param dayOfMonth  the day-of-month to set in the result, from 1 to 28-31
 * @return an {@code OffsetDateTime} based on this date-time with the requested day, not null
 * @throws DateTimeException if the day-of-month value is invalid
 * @throws DateTimeException if the day-of-month is invalid for the month-year
 */
public OffsetDateTime withDayOfMonth(int dayOfMonth) {
  return with(dateTime.withDayOfMonth(dayOfMonth), offset);
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Returns a copy of this {@code ZonedDateTime} with the day-of-month value altered.
 * <p>
 * This operates on the local time-line,
 * {@link LocalDateTime#withDayOfMonth(int) changing the day-of-month} of the local date-time.
 * This is then converted back to a {@code ZonedDateTime}, using the zone ID
 * to obtain the offset.
 * <p>
 * When converting back to {@code ZonedDateTime}, if the local date-time is in an overlap,
 * then the offset will be retained if possible, otherwise the earlier offset will be used.
 * If in a gap, the local date-time will be adjusted forward by the length of the gap.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param dayOfMonth  the day-of-month to set in the result, from 1 to 28-31
 * @return a {@code ZonedDateTime} based on this date-time with the requested day, not null
 * @throws DateTimeException if the day-of-month value is invalid
 * @throws DateTimeException if the day-of-month is invalid for the month-year
 */
public ZonedDateTime withDayOfMonth(int dayOfMonth) {
  return resolveLocal(dateTime.withDayOfMonth(dayOfMonth));
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Returns a copy of this {@code ZonedDateTime} with the day-of-month value altered.
 * <p>
 * This operates on the local time-line,
 * {@link LocalDateTime#withDayOfMonth(int) changing the day-of-month} of the local date-time.
 * This is then converted back to a {@code ZonedDateTime}, using the zone ID
 * to obtain the offset.
 * <p>
 * When converting back to {@code ZonedDateTime}, if the local date-time is in an overlap,
 * then the offset will be retained if possible, otherwise the earlier offset will be used.
 * If in a gap, the local date-time will be adjusted forward by the length of the gap.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param dayOfMonth  the day-of-month to set in the result, from 1 to 28-31
 * @return a {@code ZonedDateTime} based on this date-time with the requested day, not null
 * @throws DateTimeException if the day-of-month value is invalid
 * @throws DateTimeException if the day-of-month is invalid for the month-year
 */
public ZonedDateTime withDayOfMonth(int dayOfMonth) {
  return resolveLocal(dateTime.withDayOfMonth(dayOfMonth));
}

代码示例来源:origin: net.oneandone.ical4j/ical4j

observance.getProperties().add(rrule);
observance.getProperties().add(new DtStart(String.format(DATE_TIME_TPL, startDate.withMonth(transitionRule.getMonth().getValue())
                                                    .withDayOfMonth(transitionRule.getDayOfMonthIndicator())
                                                    .with(transitionRule.getDayOfWeek()))));

相关文章