The phone has been lying for a long time without a battery. After I inserted the battery I turn on the phone. It has my application installed with an Activity that starts immediately when the phone is turned on. She requests this date and time.

 String mDate = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss", mLocale).format(new Date()); 

Where

 mLocale = new Locale("ru", "RU"); 

or

 mLocale = Locale.getDefault(); 

that is, tried and so and so. The mDate string mDate displayed in the message:

 Toast.makeText(this, mDate, Toast.LENGTH_LONG).show(); 

But the date is not true! Displayed January 1, 2012 and 4:00 am. Is there any way to call the system command to synchronize dates and times before requesting them? That is something like this:

 synchronizeTime(); // дождаться синхронизации времени String mDate = ...; // получить настоящее корректное время Toast.makeText(this, mDate, ...).show(); // показать время 

Or, at least, to create some normal BroadcastReceiver with an event of something like android.intent.action.TIMEZONE_CHANGED .

  • there is no system. You can synchronize the time via the Internet with any server before requesting it. - Vladyslav Matviienko

0