0

I would like to change timezone on AndroidThings device on Raspberry PI3. I have already checked here and here . This last one using adb date somedate works, but after losing power, the date resets itself.

Is there anyway that we could set timezone from Java or running a shell? The required Timezone of the device is received from server.

MRodrigues
  • 1,927
  • 1
  • 17
  • 22
  • While trying to achieve the dynamic timezone I found at that I can set timezone permanently trough shell command with root privileges: `setprop persist.sys.timezone "Atlantic/Madeira` – MRodrigues Oct 23 '17 at 14:39

2 Answers2

2

With DP6 you can use the TimeManager API without requesting for the permission in the manifest.

new TimeManager().setTimeZone(String timezone)
Keith Leow
  • 56
  • 5
0

For now on android Things 5.1 Devpreview the only way I found out to be able to change timezone dynamically trough Java is using command shell:

String command = "setprop persist.sys.timezone Atlantic/Madeira". 
try{
    Runtime.getRuntime().exec(command);
}catch(IOException e){
    //Deal with the exception according to your priest teachings
}

You can check new date on adb adb shell date or on runtime by instanciating a Datetime object.

Let me know if you find out a better way!

MRodrigues
  • 1,927
  • 1
  • 17
  • 22