List of usage examples for org.joda.time YearMonthDay YearMonthDay
public YearMonthDay(Object instant)
From source file:com.moss.joda.swing.PopupCalendar.java
License:Open Source License
public PopupCalendar() { setLayout(new BorderLayout()); add(view);/*from w w w .j a va 2 s .c om*/ view.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { value = new YearMonthDay(view.getSelectedDate()); setVisible(false); fireSelection(); System.out.println("Selected " + value); } }); view.setTraversable(true); }
From source file:com.moss.jodapersist.YearMonthDayUserType.java
License:Open Source License
public Object nullSafeGet(ResultSet resultSet, String[] names, Object arg2) throws HibernateException, SQLException { Object o = resultSet.getObject(names[0]); if (o == null) { return null; } else if (sqltype.equals(DB_FORMAT_NUMERIC)) { long ymd = resultSet.getLong(names[0]); return longToYearMonthDay(ymd); } else if (sqltype.equals(DB_FORMAT_DATETIME)) { Timestamp timestamp = resultSet.getTimestamp(names[0], storageCalendar); YearMonthDay ymd = new YearMonthDay(timestamp.getTime()); return ymd; } else if (sqltype.equals(this.DB_FORMAT_STRING)) { String timeStr = resultSet.getString(names[0]); String[] parts = timeStr.split("-"); YearMonthDay ymd = new YearMonthDay(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2])); return ymd; } else//from ww w .jav a2s . co m throw new Error("No valid sqlType specified!"); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.administrativeOffice.student.RegistrationConclusionProcess.java
License:Open Source License
@Atomic public static void run(final RegistrationConclusionBean conclusionBean) { final Registration registration = conclusionBean.getRegistration(); if (registration.isBolonha()) { final CycleCurriculumGroup cycleCurriculumGroup = conclusionBean.getCycleCurriculumGroup(); registration.conclude(cycleCurriculumGroup); if (conclusionBean.hasEnteredConclusionDate()) { checkEnteredConclusionDate(conclusionBean); cycleCurriculumGroup.editConclusionInformation(AccessControl.getPerson(), cycleCurriculumGroup.getFinalAverage(), new YearMonthDay(conclusionBean.getEnteredConclusionDate()), conclusionBean.getObservations()); }// w w w .j a va 2 s . com } else { registration.conclude(); if (conclusionBean.hasEnteredConclusionDate()) { checkEnteredConclusionDate(conclusionBean); registration.editConclusionInformation(AccessControl.getPerson(), registration.getFinalAverage(), new YearMonthDay(conclusionBean.getEnteredConclusionDate()), conclusionBean.getObservations()); } } }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.pedagogicalCouncil.delegates.RemoveDelegate.java
License:Open Source License
@Atomic public static void run(PersonFunction personFunction, LocalDate newEndDate) throws FenixServiceException { check(RolePredicates.PEDAGOGICAL_COUNCIL_PREDICATE); Student student = personFunction.getPerson().getStudent(); if (!personFunction.getBeginDate().isBefore(newEndDate)) { throw new FenixServiceException("error.personFunction.endDateBeforeBeginDate"); } else {/*from w w w . j a v a2 s . co m*/ try { personFunction.setOccupationInterval(personFunction.getBeginDate(), new YearMonthDay(newEndDate)); } catch (DomainException e) { throw new FenixServiceException(e.getMessage()); } if (student.getAllActiveDelegateFunctions().isEmpty()) { student.getPerson().removePersonRoles(Role.getRoleByRoleType(RoleType.DELEGATE)); } } }
From source file:net.sourceforge.fenixedu.domain.Attends.java
License:Open Source License
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"); }/*from w w w . ja v a2 s .co m*/ 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); }
From source file:net.sourceforge.fenixedu.domain.Attends.java
License:Open Source License
public WeeklyWorkLoad getWeeklyWorkLoadOfPreviousWeek() { 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"); }/*from www .j a va2 s . c o m*/ final int previousWeekOffset = currentWeekOffset - 1; for (final WeeklyWorkLoad weeklyWorkLoad : getWeeklyWorkLoadsSet()) { if (weeklyWorkLoad.getWeekOffset().intValue() == previousWeekOffset) { return weeklyWorkLoad; } } return null; }
From source file:net.sourceforge.fenixedu.domain.DegreeCurricularPlan.java
License:Open Source License
private void oldStructureFieldsChange(Date inicialDate, Date endDate, Integer degreeDuration, Integer minimalYearForOptionalCourses, Double neededCredits, MarkType markType, Integer numerusClausus, String annotation) {/* www. ja v a 2s .com*/ if (inicialDate == null) { throw new DomainException("degreeCurricularPlan.inicialDate.not.null"); } else if (degreeDuration == null) { throw new DomainException("degreeCurricularPlan.degreeDuration.not.null"); } else if (minimalYearForOptionalCourses == null) { throw new DomainException("degreeCurricularPlan.minimalYearForOptionalCourses.not.null"); } this.setInitialDateYearMonthDay(inicialDate != null ? new YearMonthDay(inicialDate) : new YearMonthDay()); this.setEndDateYearMonthDay(endDate != null ? new YearMonthDay(endDate) : null); this.setDegreeDuration(degreeDuration); this.setMinimalYearForOptionalCourses(minimalYearForOptionalCourses); this.setNeededCredits(neededCredits); this.setMarkType(markType); this.setNumerusClausus(numerusClausus); this.setAnotation(annotation); }
From source file:net.sourceforge.fenixedu.domain.student.curriculum.ConclusionProcess.java
License:Open Source License
@Deprecated public YearMonthDay getConclusionYearMonthDay() { return new YearMonthDay(getConclusionDate()); }
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
License:Open Source License
public YearMonthDay calculateConclusionDate() { if (isBolonha()) { return getLastStudentCurricularPlan().getLastApprovementDate(); } else {/*from w w w .jav a 2 s . c o m*/ YearMonthDay result = null; for (final StudentCurricularPlan plan : getStudentCurricularPlansSet()) { final YearMonthDay date = plan.getLastApprovementDate(); if (date != null && (result == null || result.isBefore(date))) { result = date; } } if (getDegreeType() == DegreeType.MASTER_DEGREE) { final LocalDate date = getDissertationThesisDiscussedDate(); if (date != null && (result == null || result.isBefore(date))) { result = new YearMonthDay(date); } if (result == null && hasState(RegistrationStateType.SCHOOLPARTCONCLUDED)) { return getFirstRegistrationState(RegistrationStateType.SCHOOLPARTCONCLUDED).getStateDate() .toYearMonthDay(); } } if (result == null && hasState(RegistrationStateType.CONCLUDED)) { return getFirstRegistrationState(RegistrationStateType.CONCLUDED).getStateDate().toYearMonthDay(); } return result; } }
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
License:Open Source License
public void editStartDates(final LocalDate startDate, final LocalDate homologationDate, final LocalDate studiesStartDate) { editStartDates(new YearMonthDay(startDate), new YearMonthDay(homologationDate), new YearMonthDay(studiesStartDate)); }