org.joda.time.LocalDate#withDayOfMonth ( )源码实例Demo

下面列出了org.joda.time.LocalDate#withDayOfMonth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CalendarPicker   文件: MyConfig.java
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;
    }
 
源代码2 项目: CalendarPicker   文件: MyConfig.java
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;
    }
 
源代码3 项目: onetwo   文件: DateRangeStaticFacotry.java
public static Collection<DateRange> splitAsDateRangeByMonth(LocalDate start, LocalDate end){
	
	Set<DateRange> dates = new LinkedHashSet<DateRange>();
	dates.add(new DateRange(start, start.withDayOfMonth(start.dayOfMonth().getMaximumValue())));
	
	LocalDate startDateOfMonth = start.withDayOfMonth(start.dayOfMonth().getMinimumValue()).plusMonths(1);
	while(!startDateOfMonth.isAfter(end)){
		LocalDate endDateOfWeek = startDateOfMonth.withDayOfMonth(startDateOfMonth.dayOfMonth().getMaximumValue());
		if(endDateOfWeek.isAfter(end)){
			endDateOfWeek = end;
		}
		DateRange dr = new DateRange(startDateOfMonth, endDateOfWeek);
		dates.add(dr);
		startDateOfMonth = startDateOfMonth.plusMonths(1);
	}
	return dates;
}
 
源代码4 项目: prayer-times-android   文件: ImsakiyeFragment.java
public ImsakiyeAdapter(Context context) {
    LocalDate now = LocalDate.now();
    today = now.getDayOfMonth();
    date = now.withDayOfMonth(1);
    daysInMonth = date.dayOfMonth().getMaximumValue();


    inflater = LayoutInflater.from(context);
}
 
源代码5 项目: prayer-times-android   文件: ImsakiyeFragment.java
public ImsakiyeAdapter(Context context) {
    LocalDate now = LocalDate.now();
    today = now.getDayOfMonth();
    date = now.withDayOfMonth(1);
    daysInMonth = date.dayOfMonth().getMaximumValue();


    inflater = LayoutInflater.from(context);
}
 
源代码6 项目: objectlabkit   文件: LocalDateIMMDateCalculator.java
/**
 * 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);
}
 
源代码7 项目: estatio   文件: TurnoverAnalysisService.java
LocalDate getStartDateToUse(final AggregationAnalysisReportForConfig report){
    final Occupancy occupancy = report.getTurnoverReportingConfig().getOccupancy();
    LocalDate occStartDateOrNull = null;
    try {
        occStartDateOrNull = occupancy.getEffectiveInterval().startDate();
    } catch (Exception e) {
        LOG.warn(String.format("Problem with occupancy %s on lease %s", occupancy.toString(), occupancy.getLease().getReference()));
        LOG.warn(e.getMessage());
    }

    return occStartDateOrNull == null ? TurnoverAggregationService.MIN_AGGREGATION_DATE : occStartDateOrNull.withDayOfMonth(1);

}
 
源代码8 项目: estatio   文件: TurnoverAggregationService.java
public void aggregateTurnoversForLease(final Lease lease, final LocalDate startDate, final LocalDate endDate, final boolean maintainOnly){
    //since we analyze all previous and next leases with all associated configs, any config with type prelimninary and frequency monthly will do
    TurnoverReportingConfig firstConfigCandidate = null;
    for (Occupancy o : lease.getOccupancies()){
        final TurnoverReportingConfig c = turnoverReportingConfigRepository
                .findByOccupancyAndTypeAndFrequency(o, Type.PRELIMINARY, Frequency.MONTHLY).stream().findFirst()
                .orElse(null);
        if (c!=null && firstConfigCandidate==null ){
            firstConfigCandidate = c;
        }
    }

    if (firstConfigCandidate==null) return;

    LocalDate startDateToUse = startDate==null || startDate.isBefore(MIN_AGGREGATION_DATE) ? MIN_AGGREGATION_DATE.minusMonths(23).withDayOfMonth(1) : startDate.withDayOfMonth(1);
    LocalDate endDateToUse = endDate==null ? clockService.now().withDayOfMonth(1).plusMonths(23) : endDate.withDayOfMonth(1);

    if (endDateToUse.isBefore(startDateToUse)) return;

    // since we look 24 months ahead the aggregations to be made are
    List<LocalDate> turnoverDates = new ArrayList<>();
    turnoverDates.add(startDateToUse.withDayOfMonth(1));
    LocalDate d = startDateToUse.plusMonths(24);
    while (!d.isAfter(endDateToUse)){
        turnoverDates.add(d.withDayOfMonth(1));
        d = d.plusMonths(24);
    }

    if (turnoverDates.isEmpty()) return;

    if (maintainOnly){
        aggregate(turnoverDates.get(0), firstConfigCandidate, null, true);
    } else {
        for (LocalDate toDate : turnoverDates) {
            aggregate(toDate, firstConfigCandidate, null, maintainOnly);
        }
    }

}
 
源代码9 项目: NCalendar   文件: CalendarUtil.java
/**
 * 获得两个日期距离几个月
 *
 * @return
 */
public static int getIntervalMonths(LocalDate date1, LocalDate date2) {
    date1 = date1.withDayOfMonth(1);
    date2 = date2.withDayOfMonth(1);
    return Months.monthsBetween(date1, date2).getMonths();
}