I tried adb shell command adb shell date 1318349236
We used below code to execute the above command
StringBuffer cmdOut = new StringBuffer();
Process process;
process = Runtime.getRuntime().exec(cmd);
InputStreamReader r = new InputStreamReader(process.getInputStream());
BufferedReader bufReader = new BufferedReader(r);
char[] buf = new char[4096];
int nRead = 0;
while ((nRead = bufReader.read(buf)) > 0) {
cmdOut.append(buf, 0, nRead);
}
bufReader.close();
tried through calender
//set Time to device
Calendar c = Calendar.getInstance();
c.set(2013, 8, 15, 12, 34, 56);
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
am.setTime(c.getTimeInMillis());
// and set in Manifest.xml
<!-- Allows applications to set the system time -->
<permission android:name="android.permission.SET_TIME"
android:protectionLevel="signature/system"
/>
Here, SET_Time permission issue is there, its saying to root the device or to keep app in system/app folder which I do not want.