I'm writing a simple app to monitor sync activities on Android and am stuck with SyncInfo.startTime
which returns a value based on SystemClock.elapsedRealTime()
. How do I convert this value to a regular Date
object?
Asked
Active
Viewed 2,647 times
4

Leonardo Pessoa
- 190
- 2
- 11
-
This link shows a discussion on setting the base time of a `Chronometer` instance, but it doesn't allow me to set a elapsed time and retrieve the real date/time, which is what I want. – Leonardo Pessoa May 01 '13 at 13:40
-
i have also search on it i dn't find right solution on this – stackoverflow May 01 '13 at 13:41
1 Answers
12
Found a solution to the problem:
new Date(System.currentTimeMillis()
- SystemClock.elapsedRealtime()
+ elapsedTime);
where elapsedTime
is the time I receive from Android. As far as I've tested, this seems to return the correct date/time for an elapsed time. I'm just not very fond of this answer because Google warns not to use System.currentTimeMillis()
. Unless someone has a better answer, I'm closing this question as answered.

Leonardo Pessoa
- 190
- 2
- 11