Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

切换时区后,选中日期后,时间戳异常 #23

Closed
walker0406 opened this issue Jun 26, 2021 · 0 comments
Closed

切换时区后,选中日期后,时间戳异常 #23

walker0406 opened this issue Jun 26, 2021 · 0 comments

Comments

@walker0406
Copy link

/**DateTimeController
* 日期发生变化
*/
private fun onDateTimeChanged() {
syncDateData()
Log.d("DateTimePicker","$mYear-$mMonth-$mDay $mHour:$mMinute:$mSecond")

    millisecond = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        LocalDateTime.of(mYear, mMonth, mDay, mHour, mMinute, mSecond)
            .toInstant(ZoneOffset.ofHours(8)).toEpochMilli()
    } else {
        val mCalendar = Calendar.getInstance()
        mCalendar.set(mYear, mMonth-1, mDay, mHour, mMinute, mSecond)
        mCalendar.timeInMillis
    }

    if (mOnDateTimeChangedListener != null) {
        mOnDateTimeChangedListener?.invoke(millisecond)
    }
}

millisecond = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
LocalDateTime.of(mYear, mMonth, mDay, mHour, mMinute, mSecond)
.toInstant(ZoneOffset.ofHours(8)).toEpochMilli()
} 为什么有这一段

@loper7 loper7 closed this as completed in 6d7a7e2 Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant