【发布时间】:2015-05-22 16:56:14
【问题描述】:
我正在使用此代码在 android 中生成日期选择器。
DatePickerDialog datePicker = new DatePickerDialog(this, datePickerListener, y, m, d);
datePicker.getDatePicker().setMaxDate(System.currentTimeMillis());
现在max 日期是当前日期。我想把它设置为 14 年前。我该怎么做?
【问题讨论】:
-
使用
System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 365.25 * 14)? -
现在最大日期是:2014 年 10 月
-
抱歉,我忘记了乘数。更新(毫秒 * 秒 * 分钟 * 每日小时 * 年天数 * 年数)。它可能是一个预先计算好的常数:441806400000
-
@DerGolem:谢谢。它现在正在工作。
标签: android datepicker