public void setDate ( Calendar to ) { // Navigate from the current date // to the new date navigateMonth ( calendar , to ) ; // Select the day-of-month. clickDay ( to . get ( Calendar . DATE ) ) ; Calendar cal = calendar ; cal . set ( Calendar . YEAR , to . get ( Calendar . YEAR ) ) ; cal . set ( Calendar . MONTH , to . get ( Calendar . MONTH ) ) ; cal . set ( Calendar . DATE , to . get ( Calendar . DATE ) ) ; }
This is the main function of the DatePicker object to select the date specified by the input parameter . It will calculate how many time needed to click on the next month or previous month button to arrive at the correct month and year in the input parameters . It then click on the day - of - month tablet to select the correct day - of - month as specified in the input param .