//添加依赖
compile 'com.contrarywind:Android-PickerView:3.2.7'
//代码
Calendar selectedDate = Calendar.getInstance(); Calendar startDate = Calendar.getInstance(); Calendar endDate = Calendar.getInstance(); //选择的起始时间 startDate.set(2017,0,1); //选择的结束时间endDate.set(2020,0,1),也可设置为当前日期endDate.get(Calendar.DATE)。 endDate.get(Calendar.DATE); timePickerView = new TimePickerView.Builder(mContext, new TimePickerView.OnTimeSelectListener() { @Override public void onTimeSelect(Date date, View v) { selctTime = date.getTime(); dataBinding.stvCostData.setRightString(TimeUtils.formatDateForPoint(selctTime)); } }).setType(new boolean[]{true, true, true, false, false, false})//需要时分秒改为true .setLabel("年", "月", "日", "", "", "") .isCenterLabel(false) .setDividerColor(Color.DKGRAY) .setContentSize(21) .setDate(selectedDate) .setRangDate(startDate, endDate) .setDecorView(null).build();