本文整理了Java中org.threeten.bp.LocalDate.withDayOfMonth()
方法的一些代码示例,展示了LocalDate.withDayOfMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.withDayOfMonth()
方法的具体详情如下:
包路径:org.threeten.bp.LocalDate
类名称:LocalDate
方法名:withDayOfMonth
[英]Returns a copy of this date with the day-of-month altered. If the resulting date is invalid, an exception is thrown.
This instance is immutable and unaffected by this method call.
[中]返回此日期的副本,更改了月份的日期。如果结果日期无效,将引发异常。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: prolificinteractive/material-calendarview
@Override public int indexOf(final CalendarDay day) {
return (int) Period
.between(min.getDate().withDayOfMonth(1), day.getDate().withDayOfMonth(1))
.toTotalMonths();
}
代码示例来源:origin: prolificinteractive/material-calendarview
private int getWeekCountBasedOnMode() {
int weekCount = calendarMode.visibleWeeksCount;
final boolean isInMonthsMode = calendarMode.equals(CalendarMode.MONTHS);
if (isInMonthsMode && mDynamicHeightEnabled && adapter != null && pager != null) {
final LocalDate cal = adapter.getItem(pager.getCurrentItem()).getDate();
final LocalDate tempLastDay = cal.withDayOfMonth(cal.lengthOfMonth());
weekCount = tempLastDay.get(WeekFields.of(firstDayOfWeek, 1).weekOfMonth());
}
return showWeekDays ? weekCount + DAY_NAMES_ROW : weekCount;
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Returns a copy of this {@code LocalDateTime} with the day-of-month altered.
* If the resulting {@code LocalDateTime} is invalid, an exception is thrown.
* The time 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 a {@code LocalDateTime} 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 LocalDateTime withDayOfMonth(int dayOfMonth) {
return with(date.withDayOfMonth(dayOfMonth), time);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Returns a copy of this {@code LocalDateTime} with the day-of-month altered.
* If the resulting {@code LocalDateTime} is invalid, an exception is thrown.
* The time 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 a {@code LocalDateTime} 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 LocalDateTime withDayOfMonth(int dayOfMonth) {
return with(date.withDayOfMonth(dayOfMonth), time);
}
代码示例来源:origin: shrikanth7698/Collapsible-Calendar-View-Android
public CalendarAdapter(Context context) {
this.mCal = LocalDate.now().withDayOfMonth(1);
mInflater = LayoutInflater.from(context);
refresh();
}
代码示例来源:origin: shrikanth7698/Collapsible-Calendar-View-Android
public void onItemClicked(View view, LocalDate day) {
select(day);
LocalDate cal = mAdapter.getCalendar();
int newYear = day.getYear();
int newMonth = day.getMonthValue() - 1;
int oldYear = cal.getYear();
int oldMonth = cal.getMonthValue();
if (newMonth != oldMonth) {
LocalDate d = day.withDayOfMonth(1);
mAdapter.setDate(d);
if (newYear > oldYear || newMonth > oldMonth) {
mCurrentWeekIndex = 0;
}
if (newYear < oldYear || newMonth < oldMonth) {
mCurrentWeekIndex = -1;
}
if (mListener != null) {
mListener.onMonthChange();
}
reload();
}
if (mListener != null) {
mListener.onItemClick(view);
}
}
代码示例来源:origin: ThreeTen/threetenbp
case ALIGNED_DAY_OF_WEEK_IN_MONTH: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH));
case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR));
case DAY_OF_MONTH: return withDayOfMonth((int) newValue);
case DAY_OF_YEAR: return withDayOfYear((int) newValue);
case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);
代码示例来源:origin: org.threeten/threetenbp
case ALIGNED_DAY_OF_WEEK_IN_MONTH: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH));
case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR));
case DAY_OF_MONTH: return withDayOfMonth((int) newValue);
case DAY_OF_YEAR: return withDayOfYear((int) newValue);
case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);
内容来源于网络,如有侵权,请联系作者删除!