1
我可以更改當天的突出顯示(用紅色圈出)。這是當天顯示系統,但我的應用程序工作在不同的時區,所以我如何取消突出顯示當天或將其更改爲另一天。更改日期選擇器對話框當前日期 - android java
private void setDateTimeField() {
billDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
billDateDialog.show();
billDateDialog.updateDate(billDateCal.get(Calendar.YEAR), billDateCal.get(Calendar.MONTH), billDateCal.get(Calendar.DAY_OF_MONTH));
}
});
billDateDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
// Bills need to be set to 00.00 hours. DST needs to be ignored because changing to other timezones with no DST will cause problems with days changing to the day before.
long correctedTime = new DayLightSavings(year, monthOfYear, dayOfMonth, timeZone).getCorrectedTime();
billDateCal.setTimeInMillis(correctedTime);
billDate.setText(dateFormatter.format(billDateCal.getTimeInMillis()));
}
},billDateCal.get(Calendar.YEAR), billDateCal.get(Calendar.MONTH), billDateCal.get(Calendar.DAY_OF_MONTH));
// Do not allow selection of <= today's date.
// TODO Dialogue needs to be based on timezone selection.
long oneDay = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
long oldRawOffset = TimeZone.getDefault().getRawOffset();
long newRawOffset = timeZone.getRawOffset();
long rawOffset = oldRawOffset - newRawOffset;
// TODO fix dialogue to display the correct timezone current day.
billDateDialog.getDatePicker().setMinDate(Calendar.getInstance().getTimeInMillis() + oneDay - rawOffset);
}
什麼是當前良好的應用程序時間? – jeorfevre
這可能有幫助 https://stackoverflow.com/questions/26310750/how-to-set-a-specific-date-in-date-picker-in-android –
好的應用程序時間是第14日 – Mazz