Primefaces calendar component show only month and year

后端 未结 12 1884
南笙
南笙 2020-12-14 03:25

primefaces calendar component is getting Date by default. Can I get only month and year without dates.

How to get only month and year

12条回答
  •  抹茶落季
    2020-12-14 03:30

    You could do in this way:

    XHTML

                     
                        
                            
                        
                    
    

    CSS

     .ui-datepicker-calendar {
        display: none;
     }
    

    BEAN

    public void onChangeDataInicio(DateViewChangeEvent event) throws ParseException {
        dataInicio = new Date();
        SimpleDateFormat dateformat = new SimpleDateFormat("dd-M-yyyy");
        String inicio = "01-"+event.getMonth() +"-" + event.getYear();
        this.dataInicio = dateformat.parse(inicio);
    
    }
    

    It worked to me!

提交回复
热议问题