Today is October 21 2014. I set me Android phone time to Oct 20 2014. What I want is the original current time from the device. I heard it possible.
What I have done is test these codes:
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy");
Time now = new Time("GMT+05:30");
now.setToNow();
now.format("%c");
String l1 = sdf.format(new Date(now.toMillis(true)));
String l2 = sdf.format(new Date(now.toMillis(false)));
String l3 = sdf.format(new Date(Calendar.getInstance(TimeZone.getTimeZone("GMT+05:30")).getTimeInMillis()));
String l4 = sdf.format(new Date(System.currentTimeMillis()));
String l5 = sdf.format(new Date(new Date().getTime()));
All of the above Strings l1,l2,l3,l3,l4,l5 have returned same date i.e "20-10-14". But I wanted the original current time i.e "21-10-14".
Any help ?