I am trying to get actual time in my android application instead of getting what the system/device returned.
Suppose today is date 3 dec and I have changed my system date to 4 dec, now I will get the date 4 dec in my application which is not correct.
I have applied following code:
val c = Calendar.getInstance()
c.timeZone = TimeZone.getTimeZone("UTC")
val hour = c.get(Calendar.HOUR_OF_DAY)
val minute = c.get(Calendar.MINUTE)
val sec = c.get(Calendar.SECOND)
val mYear1 = c.get(Calendar.YEAR)
val mMonth1 = c.get(Calendar.MONTH)
val mDay1 = c.get(Calendar.DAY_OF_MONTH)
to get the time. But this only returned the device/system date.
All I want is to get the actual date. (i.e.. 3 dec in my case not 4 dec).
I also tried to get the time from GPS, but this only returns the time from the last known location, which can get me trouble.