How to get datepicker value in date format?

后端 未结 5 1032
礼貌的吻别
礼貌的吻别 2021-02-08 05:55

I have a problem with my Datapicker

i use the code for getting date,month & year shown below

           DatePicker datePicker;
           datePicker         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-08 06:07

    You can use a custom method for setting date and month in the desired format

        private static String  pad(int c)
        {
            return c>=10 ? ""+c : "0"+c;      
        }
    

    Instead of using the values for date and month use pad(date) and pad(month)

    Hope this helps.

提交回复
热议问题