Johannes Müller Johannes Müller - 1 year ago 116
Android Question

Android DatePicker- GeorgianCalendar - 00:00:00 UTC -getTimeinMillis()

How do I set the Time of the GeorgianCalendar 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 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