I have created a app which get the time from Mobile. I want to get the Date from google or by LocationManager . so how can i get it?
Asked
Active
Viewed 41 times
1 Answers
0
well you can use new Date();
and this will return simply current date and time, also you can format date using SimpleDateFormat
of java.util
package
for example:
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("EEE, MMM dd, yyyy");
try {
String date= simpleDateFormat.format(new Date().getTime());
} catch (ParseException e) {
e.printStackTrace();
}
so this will give output like MON, NOV 27, 2017

Umar Ata
- 4,170
- 3
- 23
- 35
-
i want that if my mobile date is wrong app will get the curremt date. – Nov 28 '17 at 09:44
-
@Dom then you need to use sim clock time or any internet based time clock api – Umar Ata Nov 28 '17 at 10:50
-
@Dom refer this https://stackoverflow.com/questions/13064750/how-to-get-current-time-from-internet-in-android – Umar Ata Nov 28 '17 at 10:51