Good afternoon everyone!
I need to capture, through an android application, the UTC used on the client device to perform internal validations.
Thank you in advance!
Good afternoon everyone!
I need to capture, through an android application, the UTC used on the client device to perform internal validations.
Thank you in advance!
Use the class TimeZone.
TimeZone timeZone = TimeZone.getDefault();
String name = timeZone.getID();
The getDefault () method returns the TimeZone that the device is to use.
The method getID () returns your ID, for example Portugal
or Brazil/East
.
final Date currentTime = new Date();
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm:ss a z");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println("UTC time: " + sdf.format(currentTime));