在Android上通过Shell设置日期

问题描述:

出于调试目的,我希望在特定日期运行我的应用.当然,我可以在模拟器上手动更改日期,但是我想知道是否有一种简单的方法可以从模拟器外壳中进行操作(我知道不能通过UI进行操作).

For debugging purposes, I would like to run my app on a certain date. I can change the date manually on my emulator, of course, but I was wondering if there was a simple way to do it from the emulator shell (I know it can't be done from the UI).

按照

Passing seconds-since-epoch as per previous answer didn't work on my instance (WinXP Android SDK11 HVGA_1.6 emulator). However this particular format worked:

adb shell date -s "yyyymmdd.[[[hh]mm]ss]"

[2011年6月27日添加了语法的时间部分.]