Signed-off-by: rtc <rtc@qq.com>

pull/34/head
rtc 2 years ago
parent c2f2f6e4b5
commit 1941c059c3

@ -345,63 +345,70 @@ public class DateTimePicker extends FrameLayout {
* @return The current month in the year
*/
public int getCurrentMonth() {
return mDate.get(Calendar.MONTH);
return mDate.get(Calendar.MONTH); // 获取日期对象的月份字段
}
/**
* Set current month in the year
*
*
* @param month The month in the year
* @param month 00
*/
public void setCurrentMonth(int month) {
if (!mInitialising && month == getCurrentMonth()) {
return;
}
mDate.set(Calendar.MONTH, month);
updateDateControl();
onDateTimeChanged();
mDate.set(Calendar.MONTH, month); // 设置日期对象的月份
updateDateControl(); // 更新日期选择器控件
onDateTimeChanged(); // 通知日期时间改变
}
/**
* Get current day of the month
*
*
* @return The day of the month
* @return
*/
public int getCurrentDay() {
return mDate.get(Calendar.DAY_OF_MONTH);
return mDate.get(Calendar.DAY_OF_MONTH); // 获取日期对象的天数字段
}
/**
* Set current day of the month
*
*
* @param dayOfMonth The day of the month
* @param dayOfMonth
*/
public void setCurrentDay(int dayOfMonth) {
if (!mInitialising && dayOfMonth == getCurrentDay()) {
return;
}
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateDateControl();
onDateTimeChanged();
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth); // 设置日期对象的天数字段
updateDateControl(); // 更新日期选择器控件
onDateTimeChanged(); // 通知日期时间改变
}
/**
* Get current hour in 24 hour mode, in the range (0~23)
* @return The current hour in 24 hour mode
* 240~23
*
* @return 24
*/
public int getCurrentHourOfDay() {
return mDate.get(Calendar.HOUR_OF_DAY);
return mDate.get(Calendar.HOUR_OF_DAY); // 获取日期对象的小时字段24小时制
}
/**
*
*
* @return
*/
private int getCurrentHour() {
if (mIs24HourView){
return getCurrentHourOfDay();
} else {
int hour = getCurrentHourOfDay();
if (hour > HOURS_IN_HALF_DAY) {
return hour - HOURS_IN_HALF_DAY;
} else {
return hour == 0 ? HOURS_IN_HALF_DAY : hour;
if (mIs24HourView) { // 如果是24小时制
return getCurrentHourOfDay(); // 直接获取当前的小时
} else { // 如果是12小时制
int hour = getCurrentHourOfDay(); // 获取当前的小时
if (hour > HOURS_IN_HALF_DAY) { // 如果大于12小时
return hour - HOURS_IN_HALF_DAY; // 返回减去12小时的小时数
} else { // 如果小于等于12小时
return hour == 0 ? HOURS_IN_HALF_DAY : hour; // 如果小时为0则返回12小时否则返回当前的小时
}
}
}

Loading…
Cancel
Save