Johannes Müller Johannes Müller - 9 months ago 95
Android Question

Android DatePicker- GregorianCalendar - 00:00:00 UTC - getTimeInMillis()

How do I set the Time of the GregorianCalendar to 00:00:00 UTC?

Because the following returns a Date at 10:00pm:

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))
Log.i("Kalender", String.valueOf(cal.getTimeInMillis()));


Look at Calendar's Calendar.getInstance(timeZone) method it already return of new object of gregorian calendar. You can create it for example like this one:

Calendar calendar = Calendar.getInstance();


Calendar cal = new GregorianCalendar(year, monthOfYear, dayOfMonth ,0 ,0, 0);

Actually you must set time zone after time setting