Java 类org.joda.time.YearMonthDay 实例源码

项目:astor    文件:TestGJChronology.java   
private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, GJChronology.getInstance(DateTimeZone.UTC));
    DateTime dtEnd = new DateTime(end, GJChronology.getInstance(DateTimeZone.UTC));
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(GJChronology.getInstance(DateTimeZone.UTC));
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);

    if (type == DurationFieldType.years() ||
        type == DurationFieldType.months() ||
        type == DurationFieldType.days()) {
        YearMonthDay ymdStart = new YearMonthDay(start, GJChronology.getInstance(DateTimeZone.UTC));
        YearMonthDay ymdEnd = new YearMonthDay(end, GJChronology.getInstance(DateTimeZone.UTC));
        assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
        assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
}
项目:astor    文件:TestISOChronology.java   
private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, ISOChronology.getInstanceUTC());
    DateTime dtEnd = new DateTime(end, ISOChronology.getInstanceUTC());
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(ISOChronology.getInstanceUTC());
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);

    if (type == DurationFieldType.years() ||
        type == DurationFieldType.months() ||
        type == DurationFieldType.days()) {
        YearMonthDay ymdStart = new YearMonthDay(start, ISOChronology.getInstanceUTC());
        YearMonthDay ymdEnd = new YearMonthDay(end, ISOChronology.getInstanceUTC());
        assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
        assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
}
项目:astor    文件:TestGJChronology.java   
private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, GJChronology.getInstance(DateTimeZone.UTC));
    DateTime dtEnd = new DateTime(end, GJChronology.getInstance(DateTimeZone.UTC));
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(GJChronology.getInstance(DateTimeZone.UTC));
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);

    if (type == DurationFieldType.years() ||
        type == DurationFieldType.months() ||
        type == DurationFieldType.days()) {
        YearMonthDay ymdStart = new YearMonthDay(start, GJChronology.getInstance(DateTimeZone.UTC));
        YearMonthDay ymdEnd = new YearMonthDay(end, GJChronology.getInstance(DateTimeZone.UTC));
        assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
        assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
}
项目:astor    文件:TestISOChronology.java   
private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, ISOChronology.getInstanceUTC());
    DateTime dtEnd = new DateTime(end, ISOChronology.getInstanceUTC());
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(ISOChronology.getInstanceUTC());
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);

    if (type == DurationFieldType.years() ||
        type == DurationFieldType.months() ||
        type == DurationFieldType.days()) {
        YearMonthDay ymdStart = new YearMonthDay(start, ISOChronology.getInstanceUTC());
        YearMonthDay ymdEnd = new YearMonthDay(end, ISOChronology.getInstanceUTC());
        assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
        assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
}
项目:fenixedu-academic    文件:ManageAssociatedObjects.java   
@Atomic
private void createAcademicOffice(AssociatedObjectsBean bean) {
    AdministrativeOffice office = new AdministrativeOffice();
    office.setAdministrativeOfficeType(bean.getType());
    new AdministrativeOfficeServiceAgreementTemplate(office);

    office.setCampus(bean.getBuilding());

    office.setName(bean.getNameLS());
    office.setCoordinator(User.findByUsername(bean.getUsername()));
    office.setRootDomainObject(Bennu.getInstance());
    Unit servicesParent =
            Bennu.getInstance().getInstitutionUnit().getSubUnits().stream().filter(x -> x.getName().equals("Services"))
                    .findAny().orElse(Bennu.getInstance().getInstitutionUnit());
    Unit.createNewUnit(office.getName(), null, null, null, new YearMonthDay(), null,
            servicesParent, AccountabilityType.readByType(AccountabilityTypeEnum.ADMINISTRATIVE_STRUCTURE), null,
            UnitClassification.CENTRAL_ORG, office, false, bean.getBuilding());
}
项目:fenixedu-academic    文件:Attends.java   
public WeeklyWorkLoad createWeeklyWorkLoad(final Integer contact, final Integer autonomousStudy, final Integer other) {

        if (contact.intValue() < 0 || autonomousStudy.intValue() < 0 || other.intValue() < 0) {
            throw new DomainException("weekly.work.load.creation.invalid.data");
        }

        if (getEnrolment() == null) {
            throw new DomainException("weekly.work.load.creation.requires.enrolment");
        }

        final int currentWeekOffset = calculateCurrentWeekOffset();
        if (currentWeekOffset < 1
                || new YearMonthDay(getEndOfExamsPeriod()).plusDays(Lesson.NUMBER_OF_DAYS_IN_WEEK).isBefore(new YearMonthDay())) {
            throw new DomainException("outside.weekly.work.load.response.period");
        }

        final int previousWeekOffset = currentWeekOffset - 1;

        final WeeklyWorkLoad lastExistentWeeklyWorkLoad =
                getWeeklyWorkLoadsSet().isEmpty() ? null : Collections.max(getWeeklyWorkLoadsSet());
        if (lastExistentWeeklyWorkLoad != null && lastExistentWeeklyWorkLoad.getWeekOffset().intValue() == previousWeekOffset) {
            throw new DomainException("weekly.work.load.for.previous.week.already.exists");
        }

        return new WeeklyWorkLoad(this, Integer.valueOf(previousWeekOffset), contact, autonomousStudy, other);
    }
项目:fenixedu-academic    文件:LessonInstanceSpaceOccupation.java   
@Override
public List<Interval> getEventSpaceOccupationIntervals(YearMonthDay startDateToSearch, YearMonthDay endDateToSearch) {

    List<Interval> result = new ArrayList<Interval>();
    Collection<LessonInstance> lessonInstances = getLessonInstancesSet();

    DateTime startDateTime = startDateToSearch != null ? startDateToSearch.toDateTimeAtMidnight() : null;
    DateTime endDateTime = endDateToSearch != null ? endDateToSearch.toDateTime(new TimeOfDay(23, 59, 59)) : null;

    for (LessonInstance lessonInstance : lessonInstances) {
        if (startDateTime == null
                || (!lessonInstance.getEndDateTime().isBefore(startDateTime) && !lessonInstance.getBeginDateTime().isAfter(
                        endDateTime))) {

            result.add(new Interval(lessonInstance.getBeginDateTime(), lessonInstance.getEndDateTime()));
        }
    }
    return result;
}
项目:fenixedu-academic    文件:IndividualCandidacyPaymentCode.java   
public static List<IndividualCandidacyPaymentCode> getAvailablePaymentCodes(final PaymentCodeType paymentCodeType,
        final YearMonthDay date) {
    List<IndividualCandidacyPaymentCode> result = new ArrayList<IndividualCandidacyPaymentCode>();

    Set<PaymentCode> individualCandidacyPaymentCodes = Bennu.getInstance().getPaymentCodesSet();
    for (PaymentCode paymentCode : individualCandidacyPaymentCodes) {

        if (!(paymentCode instanceof IndividualCandidacyPaymentCode)) {
            continue;
        }

        IndividualCandidacyPaymentCode individualCandidacyPaymentCode = (IndividualCandidacyPaymentCode) paymentCode;

        if (individualCandidacyPaymentCode.isAvailable(paymentCodeType, date)) {
            result.add(individualCandidacyPaymentCode);
        }
    }

    return result;
}
项目:fenixedu-academic    文件:Lesson.java   
public void deleteLessonInstanceIn(YearMonthDay day) {

        // throw new UnsupportedOperationException();

        if (day == null) {
            return;
        }
        LessonInstance lessonInstance = getLessonInstanceFor(day);
        if (lessonInstance == null) {
            throw new UnsupportedOperationException();
            // if (!wasFinished() &&
            // !getPeriod().getStartYearMonthDay().isAfter(day)) {
            // edit(day.plusDays(1),
            // getPeriod().getLastOccupationPeriodOfNestedPeriods().getEndYearMonthDay(),
            // getDiaSemana(),
            // getInicio(), getFim(), getFrequency(), true, day);
            // }
        } else {
            lessonInstance.delete();
        }
    }
项目:fenixedu-academic    文件:AdministrativeOfficeFeeAndInsuranceEvent.java   
@Override
protected List<AccountingEventPaymentCode> updatePaymentCodes() {
    final Money totalAmount = calculateTotalAmount();
    final AccountingEventPaymentCode nonProcessedPaymentCode = getNonProcessedPaymentCode();

    if (nonProcessedPaymentCode != null) {
        nonProcessedPaymentCode.update(new YearMonthDay(), calculatePaymentCodeEndDate(), totalAmount, totalAmount);
    } else {
        final AccountingEventPaymentCode paymentCode = getCancelledPaymentCode();
        if (paymentCode != null) {
            paymentCode.update(new YearMonthDay(), calculatePaymentCodeEndDate(), totalAmount, totalAmount);
            paymentCode.setState(PaymentCodeState.NEW);
        }
    }

    return getNonProcessedPaymentCodes();
}
项目:fenixedu-academic    文件:ExecutionSemester.java   
private void checkDatesIntersection(YearMonthDay begin, YearMonthDay end) {
    List<InfoExecutionPeriod> infoExecutionPeriods = ReadExecutionPeriods.run();
    if (infoExecutionPeriods != null && !infoExecutionPeriods.isEmpty()) {

        Collections.sort(infoExecutionPeriods, InfoExecutionPeriod.COMPARATOR_BY_YEAR_AND_SEMESTER);

        for (InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
            ExecutionSemester executionSemester = infoExecutionPeriod.getExecutionPeriod();
            YearMonthDay beginDate = executionSemester.getBeginDateYearMonthDay();
            YearMonthDay endDate = executionSemester.getEndDateYearMonthDay();
            if (begin.isAfter(endDate) || end.isBefore(beginDate) || executionSemester.equals(this)) {
                continue;
            } else {
                throw new DomainException("error.ExecutionPeriod.intersection.dates");
            }
        }
    }
}
项目:fenixedu-academic    文件:MarkSheetDispatchAction.java   
protected void checkIfEvaluationDateIsInExamsPeriod(DegreeCurricularPlan degreeCurricularPlan,
        ExecutionSemester executionSemester, Date evaluationDate, EvaluationSeason season, HttpServletRequest request,
        ActionMessages actionMessages) {
    ExecutionDegree executionDegree = degreeCurricularPlan.getExecutionDegreeByYear(executionSemester.getExecutionYear());

    if (executionDegree == null) {
        if (!season.isImprovement()
                || !degreeCurricularPlan.canSubmitImprovementMarkSheets(executionSemester.getExecutionYear())) {
            addMessage(request, actionMessages, "error.evaluationDateNotInExamsPeriod");
        }

    } else if (!(season.isSpecialAuthorization() || (evaluationDate != null && season.getExamPeriods(executionDegree,
            executionSemester).anyMatch(
            o1 -> o1.nestedOccupationPeriodsContainsDay(YearMonthDay.fromDateFields(evaluationDate)))))) {
        String dateFormat = "dd/MM/yyyy";
        String period =
                season.getExamPeriods(executionDegree, executionSemester)
                        .map(o -> o.getStartYearMonthDay().toString(dateFormat) + "-"
                                + o.getEndYearMonthDay().toString(dateFormat)).collect(Collectors.joining(", "));
        if (Strings.isNullOrEmpty(period)) {
            addMessage(request, actionMessages, "error.evaluationDateNotInExamsPeriod");
        } else {
            addMessage(request, actionMessages, "error.evaluationDateNotInExamsPeriodWithDates", period);
        }
    }
}
项目:fenixedu-academic    文件:AcademicCalendarsManagementDA.java   
public ActionForward viewAcademicCalendar(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    CalendarEntryBean bean = getRenderedObject("datesToDisplayID");

    YearMonthDay beginDate = bean.getBeginDateToDisplayInYearMonthDayFormat();
    YearMonthDay endDate = bean.getEndDateToDisplayInYearMonthDayFormat();

    if (beginDate.isAfter(endDate)) {
        addActionMessage(request, "error.begin.after.end");
        ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
        Partial begin = CalendarEntryBean.getPartialFromYearMonthDay(currentExecutionYear.getBeginDateYearMonthDay());
        Partial end = CalendarEntryBean.getPartialFromYearMonthDay(currentExecutionYear.getEndDateYearMonthDay());
        bean = CalendarEntryBean.createCalendarEntryBeanToCreateEntry(bean.getRootEntry(), bean.getRootEntry(), begin, end);
        RenderUtils.invalidateViewState("datesToDisplayID");
        return generateGanttDiagram(mapping, request, bean);
    }

    return generateGanttDiagram(mapping, request, bean);
}
项目:fenixedu-academic    文件:GratuitySituation.java   
private double calculatePenalty(final double remainingValue) {
    if (hasPenalty() && getGratuityValues().isPenaltyApplicable()) {

        int monthsToChargePenalty = 0;
        final YearMonthDay now = new YearMonthDay();

        if (getEndPaymentDate().getMonthOfYear() == now.getMonthOfYear()) {
            monthsToChargePenalty += 1;
        } else {
            monthsToChargePenalty = calculateMonthsToChargePenalty(calculateCloseDate());
        }

        return new Money(remainingValue).multiply(PENALTY_PERCENTAGE).multiply(new BigDecimal(monthsToChargePenalty))
                .getAmount().doubleValue();
    }

    return 0;
}
项目:fenixedu-academic    文件:Registration.java   
public YearMonthDay calculateConclusionDate(final CycleType cycleType) {
    if (!getDegreeType().hasAnyCycleTypes()) {
        return calculateConclusionDate();
    }

    if (!hasConcludedCycle(cycleType)) {
        throw new DomainException("Registration.hasnt.finished.given.cycle");
    }

    final StudentCurricularPlan lastStudentCurricularPlan = getLastStudentCurricularPlan();
    if (lastStudentCurricularPlan == null) {
        throw new DomainException("Registration.has.no.student.curricular.plan");
    }

    return lastStudentCurricularPlan.calculateConclusionDate(cycleType);
}
项目:fenixedu-academic    文件:Lesson.java   
public SortedSet<YearMonthDay> getAllPossibleDatesToInsertSummary() {

        HourMinuteSecond now = new HourMinuteSecond();
        YearMonthDay currentDate = new YearMonthDay();
        SortedSet<YearMonthDay> datesToInsert = getAllLessonDatesUntil(currentDate);

        for (Summary summary : getAssociatedSummaries()) {
            YearMonthDay summaryDate = summary.getSummaryDateYearMonthDay();
            datesToInsert.remove(summaryDate);
        }

        for (Iterator<YearMonthDay> iter = datesToInsert.iterator(); iter.hasNext();) {
            YearMonthDay date = iter.next();
            if (!isTimeValidToInsertSummary(now, date)) {
                iter.remove();
            }
        }

        return datesToInsert;
    }
项目:fenixedu-academic    文件:CreateLesson.java   
@Atomic
public static Lesson run(DiaSemana weekDay, Calendar begin, Calendar end, FrequencyType frequency,
        InfoRoomOccupationEditor infoRoomOccupation, InfoShift infoShift, YearMonthDay beginDate, YearMonthDay endDate)
        throws FenixServiceException {
    check(RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE);

    final ExecutionSemester executionSemester =
            FenixFramework.getDomainObject(infoShift.getInfoDisciplinaExecucao().getInfoExecutionPeriod().getExternalId());

    final Shift shift = FenixFramework.getDomainObject(infoShift.getExternalId());

    Space room = null;
    if (infoRoomOccupation != null) {
        room =
                infoRoomOccupation.getInfoRoom() != null ? SpaceUtils
                        .findAllocatableSpaceForEducationByName(infoRoomOccupation.getInfoRoom().getNome()) : null;
    }

    return new Lesson(weekDay, begin, end, shift, frequency, executionSemester, beginDate, endDate, room);
}
项目:fenixedu-academic    文件:ManageLessonDA.java   
public ActionForward prepareCreate(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    DynaActionForm manageLessonForm = (DynaActionForm) form;

    InfoShift infoShift = (InfoShift) request.getAttribute(PresentationConstants.SHIFT);
    Shift shift = FenixFramework.getDomainObject(infoShift.getExternalId());
    GenericPair<YearMonthDay, YearMonthDay> maxLessonsPeriod = shift.getExecutionCourse().getMaxLessonsPeriod();

    if (maxLessonsPeriod != null) {
        request.setAttribute("executionDegreeLessonsStartDate", maxLessonsPeriod.getLeft().toString("dd/MM/yyyy"));
        request.setAttribute("executionDegreeLessonsEndDate", maxLessonsPeriod.getRight().toString("dd/MM/yyyy"));
        manageLessonForm.set("newBeginDate", maxLessonsPeriod.getLeft().toString("dd/MM/yyyy"));
        manageLessonForm.set("newEndDate", maxLessonsPeriod.getRight().toString("dd/MM/yyyy"));
        manageLessonForm.set("createLessonInstances", Boolean.TRUE);

    } else {
        ActionErrors actionErrors = new ActionErrors();
        actionErrors.add("error.executionDegree.empty.lessonsPeriod", new ActionError(
                "error.executionDegree.empty.lessonsPeriod"));
        saveErrors(request, actionErrors);
        return mapping.findForward("EditShift");
    }

    return mapping.findForward("ShowLessonForm");
}
项目:fenixedu-academic    文件:FormationManagement.java   
protected AcademicalInstitutionUnit getFormationInstitution(final AlumniFormation formation) {
    AcademicalInstitutionUnit institutionUnit = formation.getInstitution();

    if (institutionUnit == null
            && formation.getInstitutionType() != null
            && (formation.getInstitutionType().equals(AcademicalInstitutionType.FOREIGN_INSTITUTION) || formation
                    .getInstitutionType().equals(AcademicalInstitutionType.OTHER_INSTITUTION))) {

        if (!StringUtils.isEmpty(formation.getForeignUnit())) {
            institutionUnit =
                    UniversityUnit.createNewUniversityUnit(new LocalizedString(I18N.getLocale(), formation.getForeignUnit()), null, null,
                            null, new YearMonthDay(), null, getParentUnit(formation), null, null, false, null);
            institutionUnit.setInstitutionType(formation.getInstitutionType());
        }
    }
    return institutionUnit;
}
项目:fenixedu-academic    文件:UnitGroup.java   
@Override
public boolean isMember(User user, DateTime when) {
    if (user == null) {
        return false;
    }
    YearMonthDay whenYMD = when.toYearMonthDay();
    for (Accountability accountability : user.getPerson().getParentsSet()) {
        if (accountability.getAccountabilityType().getType() == relationType && accountability.isActive(whenYMD)) {
            if (accountability.getParentParty().equals(unit)) {
                return true;
            } else if (includeSubUnits && isAncestor(unit, accountability.getParentParty(), relationType, whenYMD)) {
                return true;
            }
        }
    }
    return false;
}
项目:fenixedu-academic    文件:Lesson.java   
private SortedSet<YearMonthDay> getAllLessonInstancesDatesToCreate(YearMonthDay startDate, YearMonthDay endDate,
        Boolean createLessonInstances) {

    if (startDate != null && endDate != null && !startDate.isAfter(endDate) && createLessonInstances) {

        SortedSet<YearMonthDay> possibleLessonDates = getAllValidLessonDatesWithoutInstancesDates(startDate, endDate);
        List<LessonInstance> allLessonInstancesUntil = getAllLessonInstancesUntil(endDate.toLocalDate());

        for (LessonInstance lessonInstance : allLessonInstancesUntil) {
            possibleLessonDates.remove(lessonInstance.getDay());
        }

        return possibleLessonDates;
    }
    return new TreeSet<YearMonthDay>();
}
项目:jfixture    文件:TestAllClassDataTypesAreSupported.java   
@Test
public void creates_instance_of_YearMonthDay() {
    YearMonthDay yearMonthDay = fixture.create(YearMonthDay.class);
    assertThat(yearMonthDay, notNullValue());
    assertThat(yearMonthDay, notNullValue());
    assertThat(yearMonthDay.getYear(), is(2001));
    assertThat(yearMonthDay.getMonthOfYear(), is(1));
    assertThat(yearMonthDay.getDayOfMonth(), is(1));
}
项目:astor    文件:TestGregorianChronology.java   
public void testMaximumValue() {
    YearMonthDay ymd1 = new YearMonthDay(1999, DateTimeConstants.FEBRUARY, 1);
    DateMidnight dm1 = new DateMidnight(1999, DateTimeConstants.FEBRUARY, 1);
    Chronology chrono = GregorianChronology.getInstance();
    assertEquals(28, chrono.dayOfMonth().getMaximumValue(ymd1));
    assertEquals(28, chrono.dayOfMonth().getMaximumValue(dm1.getMillis()));
}
项目:astor    文件:TestGJChronology.java   
public void testSubtractDays() {
    // This is a test for a bug in version 1.0. The dayOfMonth range
    // duration field did not match the monthOfYear duration field. This
    // caused an exception to be thrown when subtracting days.
    DateTime dt = new DateTime
        (1112306400000L, GJChronology.getInstance(DateTimeZone.forID("Europe/Berlin")));
    YearMonthDay ymd = dt.toYearMonthDay();
    while (ymd.toDateTimeAtMidnight().getDayOfWeek() != DateTimeConstants.MONDAY) { 
        ymd = ymd.minus(Period.days(1));
    }
}
项目:astor    文件:TestGJChronology.java   
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance());
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
项目:astor    文件:TestISOChronology.java   
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1);
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
项目:astor    文件:TestGregorianChronology.java   
public void testMaximumValue() {
    YearMonthDay ymd1 = new YearMonthDay(1999, DateTimeConstants.FEBRUARY, 1);
    DateMidnight dm1 = new DateMidnight(1999, DateTimeConstants.FEBRUARY, 1);
    Chronology chrono = GregorianChronology.getInstance();
    assertEquals(28, chrono.dayOfMonth().getMaximumValue(ymd1));
    assertEquals(28, chrono.dayOfMonth().getMaximumValue(dm1.getMillis()));
}
项目:astor    文件:TestGJChronology.java   
public void testSubtractDays() {
    // This is a test for a bug in version 1.0. The dayOfMonth range
    // duration field did not match the monthOfYear duration field. This
    // caused an exception to be thrown when subtracting days.
    DateTime dt = new DateTime
        (1112306400000L, GJChronology.getInstance(DateTimeZone.forID("Europe/Berlin")));
    YearMonthDay ymd = dt.toYearMonthDay();
    while (ymd.toDateTimeAtMidnight().getDayOfWeek() != DateTimeConstants.MONDAY) { 
        ymd = ymd.minus(Period.days(1));
    }
}
项目:astor    文件:TestGJChronology.java   
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance());
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
项目:astor    文件:TestISOChronology.java   
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1);
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
项目:fenixedu-academic    文件:Unit.java   
public static Unit createNewUnit(LocalizedString unitName, String unitNameCard, Integer costCenterCode, String acronym,
        YearMonthDay beginDate, YearMonthDay endDate, Unit parentUnit, AccountabilityType accountabilityType,
        String webAddress, UnitClassification classification, AdministrativeOffice administrativeOffice,
        Boolean canBeResponsibleOfSpaces, Space campus) {

    Unit unit = new Unit();
    unit.init(unitName, unitNameCard, costCenterCode, acronym, beginDate, endDate, webAddress, classification,
            administrativeOffice, canBeResponsibleOfSpaces, campus);
    if (parentUnit != null && accountabilityType != null) {
        unit.addParentUnit(parentUnit, accountabilityType);
    }
    return unit;
}
项目:fenixedu-academic    文件:NextPossibleSummaryLessonsAndDatesBean.java   
public NextPossibleSummaryLessonsAndDatesBean(Shift shift, YearMonthDay date, HourMinuteSecond time, Space room) {
    setShift(shift);
    setDate(date);
    setExtraLesson(true);
    setTime(time);
    setRoom(room);
}
项目:fenixedu-academic    文件:NextPossibleSummaryLessonsAndDatesBean.java   
public static NextPossibleSummaryLessonsAndDatesBean getNewInstance(String value) {

        int year = Integer.parseInt(value.substring(0, 4));
        int month = Integer.parseInt(value.substring(4, 6));
        int day = Integer.parseInt(value.substring(6, 8));
        if (year == 0 || month == 0 || day == 0) {
            return null;
        }

        YearMonthDay date = new YearMonthDay(year, month, day);
        Lesson lesson = FenixFramework.getDomainObject(value.substring(8));
        NextPossibleSummaryLessonsAndDatesBean bean = new NextPossibleSummaryLessonsAndDatesBean(lesson, date);

        return bean;
    }
项目:fenixedu-academic    文件:Qualification.java   
public void edit(Person person, Country country, String branch, YearMonthDay dateYearMonthDay, String degree,
        String degreeRecognition, YearMonthDay equivalenceDateYearMonthDay, String equivalenceSchool, String mark,
        String school, String specializationArea, String title, QualificationType type, String year, String designation,
        Partial attendedBegin, Partial attendedEnd) {
    Person personLogin = AccessControl.getPerson();
    if (personLogin != null) {
        setModifiedBy(personLogin);
    }
    setBranch(branch);
    setDateYearMonthDay(dateYearMonthDay);
    setDegree(degree);
    setDegreeRecognition(degreeRecognition);
    setEquivalenceDateYearMonthDay(equivalenceDateYearMonthDay);
    setEquivalenceSchool(equivalenceSchool);
    setLastModificationDateDateTime(new DateTime());
    setMark(mark);
    setSchool(school);
    setSpecializationArea(specializationArea);
    setTitle(title);
    setType(type);
    setYear(year);
    setDesignation(designation);
    setAttendedBegin(attendedBegin);
    setAttendedEnd(attendedEnd);
    setPerson(person);
    setCountry(country);

}
项目:fenixedu-academic    文件:CountryUnit.java   
@Override
public void edit(LocalizedString unitName, String unitNameCard, Integer unitCostCenter, String acronym,
        YearMonthDay beginDate, YearMonthDay endDate, String webAddress, UnitClassification classification,
        Department department, Degree degree, AdministrativeOffice administrativeOffice, Boolean canBeResponsibleOfSpaces,
        Space campus) {

    super.edit(unitName, unitNameCard, unitCostCenter, acronym, beginDate, endDate, webAddress, classification, department,
            degree, administrativeOffice, canBeResponsibleOfSpaces, campus);

    checkIfAlreadyExistsOneCountryWithSameAcronym(this);
}
项目:fenixedu-academic    文件:SpecializationDegreeGratuityEvent.java   
@Override
protected List<AccountingEventPaymentCode> createPaymentCodes() {
    final EntryDTO entryDTO = calculateEntries(new DateTime()).iterator().next();

    return Collections.singletonList(AccountingEventPaymentCode.create(PaymentCodeType.TOTAL_GRATUITY, new YearMonthDay(),
            calculatePaymentCodeEndDate(), this, entryDTO.getAmountToPay(), entryDTO.getAmountToPay(), getStudent()
                    .getPerson()));
}
项目:fenixedu-academic    文件:Enrolment.java   
@Override
public YearMonthDay calculateConclusionDate() {
    if (!isApproved()) {
        throw new DomainException("error.Enrolment.not.approved");
    }
    return EvaluationConfiguration.getInstance().getEnrolmentEvaluationForConclusionDate(this)
            .map(EnrolmentEvaluation::getExamDateYearMonthDay).orElse(null);
}
项目:fenixedu-academic    文件:Accountability.java   
public Accountability(Party parentParty, Party childParty, AccountabilityType accountabilityType) {
    this();
    setParentParty(parentParty);
    setChildParty(childParty);
    setAccountabilityType(accountabilityType);
    setBeginDate(new YearMonthDay());
}
项目:fenixedu-academic    文件:AcademicServiceRequestBean.java   
public AcademicServiceRequestBean(final AcademicServiceRequestSituationType academicServiceRequestSituationType,
        final Person responsible) {
    this();
    setAcademicServiceRequestSituationType(academicServiceRequestSituationType);
    setResponsible(responsible);
    setSituationDate(new YearMonthDay());
}
项目:fenixedu-academic    文件:StandaloneIndividualCandidacy.java   
@Override
protected YearMonthDay getStartDate() {
    final ExecutionInterval interval = getCandidacyExecutionInterval().getExecutionYear();
    final YearMonthDay today = new YearMonthDay();
    return interval.isCurrent() && interval.getAcademicInterval().contains(today.toDateMidnight()) ? today : interval
            .getBeginDateYearMonthDay();
}