Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("serial")
- public static void fillMesesPeriodo(ComboBox cmb, final Integer idperiodo) throws ParseException {
- ArrayList<String> Meses = new ArrayList<String>();
- final BeanItemContainer<Meses> datosOrd = new BeanItemContainer<Meses>(Meses.class);
- for (Object obj : new PeriodoAcademicoService().select(new HashMap<String, Object>() {
- {
- put("idperiodo", idperiodo);
- }
- })) {
- PeriodoAcademico itmPeriodo = (PeriodoAcademico) obj;
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM");
- Integer cont=0;
- Date start = sdf.parse(FuncionFechas.formatDateToString(itmPeriodo.getFechaInicio(), "yyyy.MM"));
- Date end = sdf.parse(FuncionFechas.formatDateToString(itmPeriodo.getFechaFinal(), "yyyy.MM"));
- GregorianCalendar gcal = new GregorianCalendar();
- gcal.setTime(start);
- while (!gcal.getTime().after(end)) {
- Date d = gcal.getTime();
- SimpleDateFormat dateFormat = new SimpleDateFormat("MM");
- SimpleDateFormat dateanio = new SimpleDateFormat("YYYY");
- Meses.add("" + (Integer.parseInt(dateFormat.format(d))));
- if(Meses.get(cont).length()==1){
- datosOrd.addItem(new Meses("0"+Meses.get(cont), FuncionFechas.getMonthName("0"+Meses.get(cont))+"/"+Integer.parseInt(dateanio.format(d)),Integer.parseInt(dateanio.format(d))));
- }else{
- datosOrd.addItem(new Meses(Meses.get(cont), FuncionFechas.getMonthName(Meses.get(cont))+"/"+Integer.parseInt(dateanio.format(d)),Integer.parseInt(dateanio.format(d))));
- }
- cont++;
- gcal.add(Calendar.MONTH, 1);
- }
- }
- // datosOrd.sort(new Object[] { "id" }, new boolean[] { true });
- cmb.setItemCaptionPropertyId("name");
- cmb.setContainerDataSource(datosOrd);
- cmb.setNullSelectionAllowed(false);
- cmb.addStyleName(ValoTheme.COMBOBOX_ALIGN_CENTER);
- cmb.setInputPrompt("Seleccione Mes");
- cmb.select(0);
- cmb.setImmediate(true);
- }
Add Comment
Please, Sign In to add comment