我尝试将date设置为datepicker,它会显示错误...
我使用意图发送日期,它将在下一页设置... 那是我的问题...
我的代码是
声明datepicker对象,
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
并在创建fn,
DatePicker datePicker;
String mydate="2016-12-07";
我尝试使用updateDate fn设置日期,
datePicker = (DatePicker) findViewById(R.id.schedule_datePicker);
String[] dateParts = mydate.split("-");
请帮助我如何解决这个问题..
答案 0 :(得分:1)
考虑以下几点。
datePicker.updateDate(2016, 12, 7);
?答案 1 :(得分:1)
试试这段代码,我希望能帮到你..
final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
//pick_date.setText(year+"-"+monthOfYear+1+"-"+dayOfMonth);
// pick_date1 = year+"-"+monthOfYear+1+"-"+dayOfMonth;
}
};
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(BookNow.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
String pick_times=selectedHour+":"+selectedMinute;
String converted_time=LibraryHelper.ChangeDateFormat(pick_times,"HH:mm","hh:mm a");
pick_time.setText( converted_time);
}
}, hour, minute, false);//Yes 24 hour time
mTimePicker.setTitle("Select Time");
mTimePicker.show();
private void updateLabel() {
String myFormat = "yyyy-MM-dd"; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
}
答案 2 :(得分:-1)
是的,我试过这种方式来获得ans,
datePicker.updateDate(Integer.parseInt(dateParts[0]), Integer.parseInt(dateParts[1]), Integer.parseInt(dateParts[2]));