List of usage examples for org.joda.time LocalDate getYear
public int getYear()
From source file:org.vaadin.addons.tuningdatefield.TuningDateField.java
License:Apache License
protected CalendarItem[] buildMonthItems() { YearMonth calendarFirstMonth = getCalendarFirstMonth(); YearMonth calendarLastMonth = getCalendarLastMonth(); YearMonth currentMonth = YearMonth.now(); int numberOfMonths = Months.monthsBetween(calendarFirstMonth, calendarLastMonth).getMonths() + 1; CalendarItem[] calendarItems = new CalendarItem[numberOfMonths]; YearMonth month = calendarFirstMonth; LocalDate currentValue = getLocalDate(); YearMonth currentYearMonthValue = currentValue == null ? null : new YearMonth(currentValue.getYear(), currentValue.getMonthOfYear()); for (int i = 0; i < numberOfMonths; i++, month = month.plusMonths(1)) { calendarItems[i] = new CalendarItem(); calendarItems[i].setIndex(i);/*from ww w .j av a 2 s. co m*/ calendarItems[i].setRelativeDateIndex(month.getMonthOfYear()); calendarItems[i].setEnabled(true); // By default StringBuilder style = new StringBuilder(""); if (month.equals(currentMonth)) { style.append("currentmonth "); } if (currentYearMonthValue != null && month.equals(currentYearMonthValue)) { style.append("selected "); } if (cellItemCustomizer != null) { String generatedStyle = cellItemCustomizer.getStyle(month, this); if (generatedStyle != null) { style.append(generatedStyle); style.append(" "); } String tooltip = cellItemCustomizer.getTooltip(month, this); if (tooltip != null) { calendarItems[i].setTooltip(tooltip); } } if (isMonthEnabled(month)) { calendarItems[i].setEnabled(true); } String computedStyle = style.toString(); if (!computedStyle.isEmpty()) { calendarItems[i].setStyle(computedStyle); } String calendarItemContent = null; if (cellItemCustomizer != null) { calendarItemContent = cellItemCustomizer.renderMonth(currentYearMonthValue, this); } // fallback to default value if (calendarItemContent == null) { calendarItemContent = shortMonthTexts[i]; } calendarItems[i].setText(calendarItemContent); } return calendarItems; }
From source file:org.vaadin.addons.tuningdatefield.TuningDateField.java
License:Apache License
protected CalendarItem[] buildYearItems() { int calendarFirstYear = getCalendarFirstYear(); int calendarLastYear = getCalendarLastYear(); int currentYear = YearMonth.now().getYear(); int numberOfYears = calendarLastYear - calendarFirstYear + 1; CalendarItem[] calendarItems = new CalendarItem[numberOfYears]; int year = calendarFirstYear; LocalDate currentValue = getLocalDate(); Integer currentYearValue = currentValue == null ? null : currentValue.getYear(); for (int i = 0; i < numberOfYears; i++, year++) { calendarItems[i] = new CalendarItem(); calendarItems[i].setIndex(i);/*from w ww . j a va 2 s .c om*/ calendarItems[i].setRelativeDateIndex(year); calendarItems[i].setEnabled(true); StringBuilder style = new StringBuilder(""); if (year == currentYear) { style.append("currentyear "); } if (currentYearValue != null && year == currentYearValue) { style.append("selected "); } if (isYearEnabled(year)) { calendarItems[i].setEnabled(true); } if (cellItemCustomizer != null) { String generatedStyle = cellItemCustomizer.getStyle(year, this); if (generatedStyle != null) { style.append(generatedStyle); style.append(" "); } String tooltip = cellItemCustomizer.getTooltip(year, this); if (tooltip != null) { calendarItems[i].setTooltip(tooltip); } } String computedStyle = style.toString(); if (!computedStyle.isEmpty()) { calendarItems[i].setStyle(computedStyle); } String calendarItemContent = null; if (cellItemCustomizer != null) { calendarItemContent = cellItemCustomizer.renderYear(year, this); } // fallback to default value if (calendarItemContent == null) { calendarItemContent = Integer.toString(year); } calendarItems[i].setText(calendarItemContent); } return calendarItems; }
From source file:org.zkoss.ganttz.FunctionalityExposedForExtensions.java
License:Open Source License
public FunctionalityExposedForExtensions(Planner planner, PlannerConfiguration<T> configuration, GanttZKDiagramGraph diagramGraph) { this.planner = planner; this.configuration = configuration; this.adapter = configuration.getAdapter(); this.navigator = configuration.getNavigator(); this.diagramGraph = diagramGraph; final IDetailItemModifier firstLevelModifiers = configuration.getFirstLevelModifiers(); final IDetailItemModifier secondLevelModifiers = configuration.getSecondLevelModifiers(); Calendar calendarRightNow = Calendar.getInstance(); LocalDate localDateRightNow = LocalDate.fromCalendarFields(calendarRightNow); LocalDate initDate = localDateRightNow.minusYears(1); LocalDate endDate = localDateRightNow.plusYears(5); this.timeTracker = new TimeTracker( new Interval(TimeTrackerState.year(initDate.getYear()), TimeTrackerState.year(endDate.getYear())), planner.getZoomLevel(), firstLevelModifiers, secondLevelModifiers, planner); }
From source file:org.zkoss.ganttz.timetracker.zoom.DetailOneTimeTrackerState.java
License:Open Source License
public static LocalDate doYearRound(LocalDate date, boolean down) { return new LocalDate(date.getYear() + (down ? 0 : 1), 1, 1); }
From source file:pt.ist.expenditureTrackingSystem.domain.acquisitions.afterthefact.AcquisitionAfterTheFact.java
License:Open Source License
public boolean isAppiableForYear(final int year) { final LocalDate localDate = getAfterTheFactAcquisitionProcess().getInvoice().getInvoiceDate(); return localDate != null && localDate.getYear() == year; }
From source file:pt.ist.fenixedu.teacher.evaluation.domain.TeacherEvaluationInformationBean.java
License:Open Source License
public TeacherEvaluationInformationBean(TeacherEvaluationProcess teacherEvaluationProcess) { this.teacherEvaluationProcess = teacherEvaluationProcess; if (teacherEvaluationProcess.getEvaluee().getTeacher() != null) { LocalDate beginDate = new LocalDate( teacherEvaluationProcess.getFacultyEvaluationProcess().getBeginEvaluationYear(), 1, 1); LocalDate endDate = new LocalDate( teacherEvaluationProcess.getFacultyEvaluationProcess().getEndEvaluationYear(), 12, 31); setTeacherAuthorization(teacherEvaluationProcess.getEvaluee().getTeacher() .getLatestTeacherAuthorizationInInterval( new Interval(beginDate.toDateTimeAtStartOfDay(), endDate.toDateTimeAtStartOfDay())) .orElse(null));/*from w ww .ja v a 2s. co m*/ for (Professorship professorship : getTeacherEvaluationProcess().getEvaluee().getTeacher() .getProfessorships()) { if (professorship.getExecutionCourse().getExecutionPeriod().getBeginLocalDate() .getYear() >= getTeacherEvaluationProcess().getFacultyEvaluationProcess() .getBeginEvaluationYear() && professorship.getExecutionCourse().getExecutionPeriod().getBeginLocalDate() .getYear() <= getTeacherEvaluationProcess().getFacultyEvaluationProcess() .getEndEvaluationYear()) { professorships .addAll(ProfessorshipEvaluationBean.getProfessorshipEvaluationBeanSet(professorship)); } } for (ThesisEvaluationParticipant participant : teacherEvaluationProcess.getEvaluee() .getThesisEvaluationParticipantsSet()) { Thesis thesis = participant.getThesis(); if (thesis.isEvaluated() && thesis.hasFinalEnrolmentEvaluation() && thesis.getDiscussed().getYear() >= getTeacherEvaluationProcess() .getFacultyEvaluationProcess().getBeginEvaluationYear() && thesis.getDiscussed().getYear() <= getTeacherEvaluationProcess() .getFacultyEvaluationProcess().getEndEvaluationYear()) { if (participant.getType() == ThesisParticipationType.ORIENTATOR || participant.getType() == ThesisParticipationType.COORIENTATOR) { orientations.add(new OrientationBean(participant)); } if (participant.getType() == ThesisParticipationType.VOWEL || participant.getType() == ThesisParticipationType.PRESIDENT) { String descrition = Joiner.on(", ").join( BundleUtil.getString("resources.TeacherEvaluationResources", participant.getClass().getName() + "." + ThesisParticipationType.PRESIDENT.name()), participant.getThesis().getTitle(), participant.getThesis().getStudent().getPerson().getName(), participant.getThesis().getStudent().getNumber(), thesis.getDiscussed().toLocalDate().toString()); functions.add(new OrientationBean(descrition, thesis.getDiscussed().toLocalDate())); } } } for (InternalPhdParticipant internalPhdParticipant : teacherEvaluationProcess.getEvaluee() .getInternalParticipantsSet()) { LocalDate conclusionDate = internalPhdParticipant.getIndividualProcess().getConclusionDate(); if (conclusionDate != null && conclusionDate.getYear() >= getTeacherEvaluationProcess().getFacultyEvaluationProcess() .getBeginEvaluationYear() && conclusionDate.getYear() <= getTeacherEvaluationProcess().getFacultyEvaluationProcess() .getEndEvaluationYear()) { if (internalPhdParticipant.getProcessForGuiding() != null || internalPhdParticipant.getProcessForAssistantGuiding() != null) { orientations.add(new OrientationBean(internalPhdParticipant)); } ThesisJuryElement thesisJuryElement = getThesisJuryElement(internalPhdParticipant); if (thesisJuryElement != null) { String descrition = Joiner.on(", ").join( BundleUtil.getString("resources.TeacherEvaluationResources", internalPhdParticipant.getClass().getName() + "." + ThesisParticipationType.PRESIDENT.name()), internalPhdParticipant.getIndividualProcess().getThesisTitle(), internalPhdParticipant.getIndividualProcess().getStudent().getPerson().getName(), internalPhdParticipant.getIndividualProcess().getStudent().getNumber(), internalPhdParticipant.getIndividualProcess().getConclusionDate().toString()); functions.add(new OrientationBean(descrition, internalPhdParticipant.getIndividualProcess().getConclusionDate())); } } } publications.addAll( new SotisPublications().getPublications(getTeacherEvaluationProcess().getEvaluee().getUser(), teacherEvaluationProcess.getFacultyEvaluationProcess().getBeginEvaluationYear(), teacherEvaluationProcess.getFacultyEvaluationProcess().getEndEvaluationYear())); for (PersonFunction personFunction : (Collection<PersonFunction>) teacherEvaluationProcess.getEvaluee() .getParentAccountabilities(AccountabilityTypeEnum.MANAGEMENT_FUNCTION, PersonFunction.class)) { if (personFunction.getBeginDate().getYear() >= getTeacherEvaluationProcess() .getFacultyEvaluationProcess().getBeginEvaluationYear() && personFunction.getBeginDate().getYear() <= getTeacherEvaluationProcess() .getFacultyEvaluationProcess().getEndEvaluationYear() && !personFunction.getFunction().isVirtual()) { functions.add(new OrientationBean(personFunction)); } } } }
From source file:py.com.palermo.servicioarthy.impl.gestioncomercial.PortalGeneralService.java
public Meta getMetaActual(Vendedor v) throws AccesoDenegadoException { Meta R = null;/*from w ww . j a va2s . c o m*/ if (v != null) { String refExterna = v.getEmpresasid() + "," + v.getSucursalesid() + "," + v.getVendedorid(); LocalDate localDate = new LocalDate(); int mes = localDate.getMonthOfYear(); int anio = localDate.getYear(); try { R = (Meta) em.createQuery( "SELECT m from Meta m WHERE m.estado = 'ACTIVO' AND m.refExterna = ?1 AND m.mes = ?2 AND m.anio = ?3") .setParameter(1, refExterna).setParameter(2, mes).setParameter(3, anio).getSingleResult(); R.setDiasTrabajados(ConsultasPalermo.calculaDiasTrabajados(new Date())); R.setEmpresaId(v.getEmpresasid()); R.setSucursalId(v.getSucursalesid()); R.setVendedorId(new Integer(v.getVendedorid())); R.setCantidadAlcanzada(0d); } catch (Exception e) { System.err.println("No hay metas para este vendedor: " + e.getMessage()); } } return R; }
From source file:rabbit.data.internal.xml.DataStore.java
License:Apache License
@Override public List<File> getDataFiles(LocalDate start, LocalDate end, IPath location) { // Work out the number of months between the two dates, regardless of the // dateOfMonth of each date: int numMonths = (end.getYear() - start.getYear()) * 12; numMonths += end.getMonthOfYear() - start.getMonthOfYear(); List<File> result = Lists.newLinkedList(); for (; numMonths >= 0; numMonths--) { File f = getDataFile(end.minusMonths(numMonths), location); if (f.exists()) { result.add(f);/*from www. ja v a 2s .co m*/ } } return result; }
From source file:rabbit.data.internal.xml.DatatypeUtil.java
License:Apache License
/** * Checks whether the two dates are representing the same year and same month. * //from ww w.j a v a 2 s. c o m * @param cal1 The first date. * @param cal2 The second date. * @return True if both dates are representing the same year and same month. */ public static boolean isSameMonthInYear(DateTime cal1, LocalDate cal2) { return (cal1.getYear() == cal2.getYear()) && (cal1.getMonthOfYear() == cal2.getMonthOfYear()); }
From source file:rabbit.data.internal.xml.DatatypeUtil.java
License:Apache License
/** * Converts a {@link LocalDate} to {@link XMLGregorianCalendar}. The * converted calendar is a date, which means only the year, month and day of * month fields are set./*w w w. ja va 2 s . c om*/ * * @param cal The calendar to convert from. * @return The converted calendar. */ public static XMLGregorianCalendar toXmlDate(LocalDate cal) { return datatypeFactory.newXMLGregorianCalendarDate(cal.getYear(), cal.getMonthOfYear(), cal.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED); }