List of usage examples for java.time LocalDate of
public static LocalDate of(int year, int month, int dayOfMonth)
From source file:org.efaps.esjp.common.uiform.Field_Base.java
/** * @param _parameter Parameter as passed from the eFaps API * @return Return containing Html Snipplet * @throws EFapsException on error// w w w.j a va 2 s . co m */ public Return getOptionList4DateTime(final Parameter _parameter) throws EFapsException { final List<DropDownPosition> positions = new ArrayList<>(); final String dateFieldType = getProperty(_parameter, "DateFieldType", "YEAR"); switch (dateFieldType) { case "MONTH": for (final Month month : Month.values()) { final DropDownPosition pos = getDropDownPosition(_parameter, month.getValue(), month.getDisplayName(TextStyle.FULL, Context.getThreadContext().getLocale())); pos.setSelected(month.getValue() == new DateTime().getMonthOfYear()); positions.add(pos); } break; case "YEAR": default: final String fromStr = getProperty(_parameter, "From", "-10"); final String toStr = getProperty(_parameter, "To", "+10"); LocalDate start; if (StringUtils.isNumeric(fromStr)) { start = LocalDate.of(Integer.parseInt(fromStr), 1, 1); } else { start = LocalDate.now().plusYears(Integer.parseInt(fromStr)); } final LocalDate end; if (StringUtils.isNumeric(toStr)) { end = LocalDate.of(Integer.parseInt(toStr), 1, 1); } else { end = LocalDate.now().plusYears(Integer.parseInt(toStr)); } while (start.isBefore(end)) { final DropDownPosition pos = getDropDownPosition(_parameter, start.getYear(), start.getYear()); pos.setSelected(start.getYear() == new DateTime().getYear()); positions.add(pos); start = start.plusYears(1); } break; } final Return ret = new Return(); ret.put(ReturnValues.VALUES, positions); return ret; }