Johannes Müller Johannes Müller - 2 years ago 168
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()));

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download