gpt4 book ai didi

android - 我已经采取了日期选择器对话框。我想限制选择从当前日期到接下来 3 个月的日期

转载 作者:搜寻专家 更新时间:2023-11-01 08:34:57 25 4
gpt4 key购买 nike

public void DateDialog() {
DatePickerDialog.OnDateSetListener listener = new DatePickerDialog.OnDateSetListener() {

@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

long timeInMilliseconds = 0;
String givenDateString = "Tue Jun 23 16:08:28 GMT+05:30 2016";
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
try {
Date mDate = sdf.parse(givenDateString);
timeInMilliseconds = mDate.getTime();
System.out.println("Date in milli :: " + timeInMilliseconds);
} catch (ParseException e) {
e.printStackTrace();
}
view.setMaxDate(timeInMilliseconds);
datePicker.setText(dayOfMonth + "/" + monthOfYear + "/" + year);
}
};

DatePickerDialog dpDialog = new DatePickerDialog(this, listener, year, month, day);
dpDialog.show();

}

i have taken datepicker dialog. i want to restrict to select date from current date till its next 3 months

最佳答案

Calendar calendar = Calendar.getInstance();//get the current day
calendar.add(Calendar.MONTH,3);
long afterThreeMonthsinMilli=calendar.getTimeInMillis();
DatePickerDialog dpDialog = new DatePickerDialog(getActivity(), listener, mYear, mMonth, mDay);
dpDialog.getDatePicker().setMaxDate(afterThreeMonthsinMilli);
dpDialog.show();

关于android - 我已经采取了日期选择器对话框。我想限制选择从当前日期到接下来 3 个月的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37523653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com