Calendar currentCalendar = Calendar.getInstance();
Calendar endCalendar = Calendar.getInstance();
endCalendar.set(Calendar.YEAR, 2022);
endCalendar.set(Calendar.MONTH, Calendar.DECEMBER);
endCalendar.set(Calendar.DAY_OF_MONTH, 31);
endCalendar.set(Calendar.HOUR_OF_DAY, 23);
endCalendar.set(Calendar.MINUTE, 59);
endCalendar.set(Calendar.SECOND, 59);
long currentTimeInMillis = currentCalendar.getTimeInMillis();
long endTimeInMillis = endCalendar.getTimeInMillis();
long diffTimeInMillis = endTimeInMillis - currentTimeInMillis;
long days = TimeUnit.MILLISECONDS.toDays(diffTimeInMillis);
long hours = TimeUnit.MILLISECONDS.toHours(diffTimeInMillis) - TimeUnit.DAYS.toHours(days);
long minutes = TimeUnit.MILLISECONDS.toMinutes(diffTimeInMillis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(diffTimeInMillis));
long seconds = TimeUnit.MILLISECONDS.toSeconds(diffTimeInMillis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(diffTimeInMillis));
String countdownTime = "倒计时: " + String.format("%02d", days) + "天 "
+ String.format("%02d", hours) + "小时 "
+ String.format("%02d", minutes) + "分钟 "
+ String.format("%02d", seconds) + "秒";
textView.setText(countdownTime);
这样,在所有时区中都可以显示相同的倒计时了。