如何将GregorianCalendar的时间设置为00:00:00 UTC?
因为以下内容在晚上10点返回日期:
TimeZone timeZone = TimeZone.getTimeZone("UTC");
Calendar cal = Calendar.getInstance(timeZone);
cal = new GregorianCalendar(year, monthOfYear, dayOfMonth ,0 ,0, 0);
editor.putString("auswahldatum", String.valueOf(cal.getTimeInMillis() / 1000))
.apply();
Log.i("Kalender", String.valueOf(cal.getTimeInMillis()));
答案 0 :(得分:1)
查看日历的Calendar.getInstance(timeZone)
方法,它已经返回了格里高利历的新对象。你可以像这样创建它:
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(timezone);
或
Calendar cal = new GregorianCalendar(year, monthOfYear, dayOfMonth ,0 ,0, 0);
cal.setTime(date);
cal.setTimeZone(timezone);
实际上,您必须在时间设置
后设置时区