Android command modify time or program modify system time

Source: Internet
Author: User

The premise is that the phone must first obtain root; The root method is described in other chapters or on the web.

ADB shell enters Shell terminal interface

1. Set the time zone configuration of the system first

cat /data/property/persist.sys.timezone //View current time zone profile
setprop persist.sys.timezone gmt         //Modify the attribute  
2, start setting Modify current system time

Date-s "YYYYMMDD. [[[Hh]mm]ss] "or system/bin/date-s " yyyymmdd.[ [[Hh]mm]ss] "

3. See if it takes effect

Date

Second, the implementation of the code to modify the Android system time method

public void TestDate () {
try {
process process = Runtime.getruntime (). EXEC ("su");
String datetime= "20131023.112800";//Test Set time "time format Yyyymmdd.hhmmss"
Span style= "White-space:pre" > dataoutputstream os = new DataOutputStream (Process.getoutputstream ());
os.writebytes ("SetProp persist.sys.timezone gmt\n");
os.writebytes ("/system/bin/date-s" +datetime+ "\ n");
os.writebytes ("clock-w\n");
os.writebytes ("exit\n");
Os.flush ();
} catch (IOException e) {
E.printstacktrace ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.