本文整理了Java中org.joda.time.LocalDate.withDayOfMonth()
方法的一些代码示例,展示了LocalDate.withDayOfMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.withDayOfMonth()
方法的具体详情如下:
包路径:org.joda.time.LocalDate
类名称:LocalDate
方法名:withDayOfMonth
[英]Returns a copy of this date with the day of month field updated.
LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of month changed.
[中]
代码示例来源:origin: org.schoellerfamily.gedbrowser/gedbrowser-analytics
/**
* Adjust the input date to the beginning of the month.
*
* @param date the input date
* @return new date
*/
protected final LocalDate firstDayOfMonth(final LocalDate date) {
return date.withDayOfMonth(1);
}
代码示例来源:origin: yannecer/NCalendar
/**
* 获得两个日期距离几个月
*
* @return
*/
public static int getIntervalMonths(LocalDate date1, LocalDate date2) {
date1 = date1.withDayOfMonth(1);
date2 = date2.withDayOfMonth(1);
return Months.monthsBetween(date1, date2).getMonths();
}
代码示例来源:origin: pl.edu.icm.sedno/sedno-tools
private void trimDay() {
if (localDate == null) {
return;
}
if (localDate.getDayOfMonth() != NULL_REPLACEMENT) {
localDate = localDate.withDayOfMonth(NULL_REPLACEMENT);
}
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
protected Object getMinValue() {
return new LocalDate(super.getMinValue()).withDayOfMonth(1);
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
protected Object getMaxValue() {
return new LocalDate(super.getMaxValue()).withDayOfMonth(1);
}
代码示例来源:origin: net.objectlab.kit/datecalc-joda
public static LocalDate getLocalDate(final double date, final boolean use1904windowing) {
final Calendar c = ExcelDateUtil.getJavaCalendar(date, use1904windowing);
if (c == null) {
return null;
}
return new LocalDate().withYear(c.get(Calendar.YEAR)).withMonthOfYear(c.get(Calendar.MONTH) + 1).withDayOfMonth(c.get(Calendar.DAY_OF_MONTH));
}
代码示例来源:origin: Appendium/objectlabkit
public static LocalDate getLocalDate(final double date, final boolean use1904windowing) {
final Calendar c = ExcelDateUtil.getJavaCalendar(date, use1904windowing);
if (c == null) {
return null;
}
return new LocalDate().withYear(c.get(Calendar.YEAR)).withMonthOfYear(c.get(Calendar.MONTH) + 1).withDayOfMonth(c.get(Calendar.DAY_OF_MONTH));
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
protected final LocalDate getMin() {
final LocalDate v = null;
if (hasMinComplete()) {
return ((LocalDate) getMinValue()).withDayOfMonth(1);
}
return v;
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
protected final LocalDate getMax() {
final LocalDate v = null;
if (hasMaxComplete()) {
return ((LocalDate) getMaxValue()).withDayOfMonth(1);
}
return v;
}
代码示例来源:origin: org.motechproject/motech-platform-commons-date
public static LocalDate newDate(int year, int month, int day) {
return new LocalDate(DateTimeSourceUtil.timeZone())
.withYear(year)
.withMonthOfYear(month)
.withDayOfMonth(day);
}
代码示例来源:origin: maxyou/CalendarPicker
public static CalendarMonth getMonthIncludeThisDay(LocalDate localDate) {
CalendarMonth calendarMonth = new CalendarMonth();
calendarMonth.firstDayOfCurrentMonth = localDate.withDayOfMonth(1);
for (int i = 0; i < 6; i++) {//每个月最多6周,最少4周
CalendarWeek w = getWeekIncludeThisDay(calendarMonth.firstDayOfCurrentMonth.plusDays(7 * i));
if (i < 4) {
calendarMonth.calendarWeeks.addLast(w);
} else if (w.calendarDayList.getFirst().day.getMonthOfYear() == calendarMonth.firstDayOfCurrentMonth.getMonthOfYear()) {
/**
* 从第5周开始检
* 如果w的第一天的月份等于本月第一天的月份,那么这一周也算本月的周
*/
calendarMonth.calendarWeeks.addLast(w);
} else {
break;
}
}
calendarMonth.originDate = localDate;
return calendarMonth;
}
代码示例来源:origin: org.schoellerfamily.gedbrowser/gedbrowser-analytics
/**
* Adjust by the gap between children and to beginning of month.
*
* @param date the input date
* @return the adjusted date
*/
private LocalDate childAdjustment(final LocalDate date) {
if (date == null) {
return date;
}
return date.plusYears(typicals.gapBetweenChildren())
.withMonthOfYear(1).withDayOfMonth(1);
}
}
代码示例来源:origin: Appendium/objectlabkit
/**
* Assumes that the month is correct, get the day for the 2rd wednesday.
*
* @param original
* the start date
* @return the 3rd Wednesday of the month
*/
private LocalDate calculate3rdWednesday(final LocalDate original) {
final LocalDate firstOfMonth = original.withDayOfMonth(1);
LocalDate firstWed = firstOfMonth.withDayOfWeek(MONTHS_IN_QUARTER);
if (firstWed.isBefore(firstOfMonth)) {
firstWed = firstWed.plusWeeks(1);
}
return firstWed.plusWeeks(2);
}
代码示例来源:origin: org.schoellerfamily.gedbrowser/gedbrowser-analytics
/**
* Apply a standard adjustment from an ancestor's marriage date to a
* person's birth date.
*
* @param date the ancestor's marriage date
* @return the adjusted date
*/
private LocalDate ancestorAdjustment(final LocalDate date) {
if (date == null) {
return null;
}
return date.plusYears(typicals.ageAtMarriage()
+ typicals.gapBetweenChildren())
.withMonthOfYear(1).withDayOfMonth(1);
}
代码示例来源:origin: net.objectlab.kit/datecalc-joda
/**
* Assumes that the month is correct, get the day for the 2rd wednesday.
*
* @param original
* the start date
* @return the 3rd Wednesday of the month
*/
private LocalDate calculate3rdWednesday(final LocalDate original) {
final LocalDate firstOfMonth = original.withDayOfMonth(1);
LocalDate firstWed = firstOfMonth.withDayOfWeek(MONTHS_IN_QUARTER);
if (firstWed.isBefore(firstOfMonth)) {
firstWed = firstWed.plusWeeks(1);
}
return firstWed.plusWeeks(2);
}
代码示例来源:origin: com.synaptix/SynaptixWidget
private void init() {
LocalDate firstDate = new LocalDate(year, month, 1);
startDate = firstDate.withDayOfWeek(DateTimeConstants.MONDAY);
LocalDate lastDate = firstDate.withDayOfMonth(firstDate.dayOfMonth().getMaximumValue());
LocalDate endDate;
if (lastDate.getDayOfWeek() != DateTimeConstants.SUNDAY) {
endDate = lastDate.withDayOfWeek(DateTimeConstants.SUNDAY);
} else {
endDate = lastDate;
}
Duration d = new Duration(startDate.toDateMidnight(DateTimeZone.UTC), endDate.toDateMidnight(DateTimeZone.UTC));
nbWeek = ((int) d.getStandardDays() + 1) / 7;
}
代码示例来源:origin: com.manydesigns/portofino-calendar
public AbstractMonth(LocalDate referenceDateMidnight) {
logger.debug("Initializing month");
this.referenceDateMidnight = referenceDateMidnight;
logger.debug("Reference date midnight: {}", referenceDateMidnight);
monthStart = referenceDateMidnight.withDayOfMonth(1);
monthEnd = monthStart.plusMonths(1);
monthInterval = new Interval(monthStart.toDateTimeAtStartOfDay(), monthEnd.toDateTimeAtStartOfDay());
logger.debug("Month interval: {}", monthInterval);
daysCount = Days.daysIn(monthInterval).getDays();
logger.debug("Initializing {} days", daysCount);
days = createDaysArray(daysCount);
LocalDate dayStart = monthStart;
for (int i = 0; i < daysCount; i++) {
LocalDate dayEnd = dayStart.plusDays(1);
days[i] = createDay(dayStart, dayEnd);
// advance to next day
dayStart = dayEnd;
}
}
代码示例来源:origin: ManyDesigns/Portofino
public AbstractMonth(LocalDate referenceDateMidnight) {
logger.debug("Initializing month");
this.referenceDateMidnight = referenceDateMidnight;
logger.debug("Reference date midnight: {}", referenceDateMidnight);
monthStart = referenceDateMidnight.withDayOfMonth(1);
monthEnd = monthStart.plusMonths(1);
monthInterval = new Interval(monthStart.toDateTimeAtStartOfDay(), monthEnd.toDateTimeAtStartOfDay());
logger.debug("Month interval: {}", monthInterval);
daysCount = Days.daysIn(monthInterval).getDays();
logger.debug("Initializing {} days", daysCount);
days = createDaysArray(daysCount);
LocalDate dayStart = monthStart;
for (int i = 0; i < daysCount; i++) {
LocalDate dayEnd = dayStart.plusDays(1);
days[i] = createDay(dayStart, dayEnd);
// advance to next day
dayStart = dayEnd;
}
}
代码示例来源:origin: maxyou/CalendarPicker
public static CalendarWeek getWeekIncludeThisDay(LocalDate localDate) {
LocalDate monday = localDate.withDayOfWeek(DateTimeConstants.MONDAY);
LocalDate tuesday = localDate.withDayOfWeek(DateTimeConstants.TUESDAY);
LocalDate wednesday = localDate.withDayOfWeek(DateTimeConstants.WEDNESDAY);
LocalDate thursday = localDate.withDayOfWeek(DateTimeConstants.THURSDAY);
LocalDate friday = localDate.withDayOfWeek(DateTimeConstants.FRIDAY);
LocalDate saturday = localDate.withDayOfWeek(DateTimeConstants.SATURDAY);
LocalDate sunday = localDate.withDayOfWeek(DateTimeConstants.SUNDAY);
CalendarWeek calendarWeek = new CalendarWeek(
monday,
tuesday,
wednesday,
thursday,
friday,
saturday,
sunday
);
calendarWeek.firstDayOfCurrentMonth = localDate.withDayOfMonth(1);
calendarWeek.originDate = localDate;
return calendarWeek;
}
代码示例来源:origin: qcadoo/mes
private void setDefaultDateRange(final ViewDefinitionState view) {
for (ComponentState dateFromComponent : view
.tryFindComponentByReference(DeviationReportGeneratorViewReferences.DATE_FROM).asSet()) {
Date firstDayOfCurrentMonth = LocalDate.now().withDayOfMonth(1).toDate();
dateFromComponent.setFieldValue(DateUtils.toDateString(firstDayOfCurrentMonth));
}
Optional<ComponentState> maybeDateFromComponent = view
.tryFindComponentByReference(DeviationReportGeneratorViewReferences.DATE_TO);
for (ComponentState dateFromComponent : maybeDateFromComponent.asSet()) {
Date today = LocalDate.now().toDate();
dateFromComponent.setFieldValue(DateUtils.toDateString(today));
}
}
内容来源于网络,如有侵权,请联系作者删除!