Time to copy phone messages and call logs _android

Source: Internet
Author: User
Nonsense not much to say that on the code
Copy Code code as follows:

Public String Getrelativetimespanstringforiphone (long Time,long now) {
SimpleDateFormat formatter = null;
Resources res = mcontext.getresources ();
Formatter = new SimpleDateFormat ("Yy-mm-dd");
String Yearmonthday = Formatter.format (time);
if (Time>now) {
return yearmonthday;
Formatter = new SimpleDateFormat ("E");
String DayOfWeek = Formatter.format (time);

Formatter = new SimpleDateFormat ("kk:mm");
String hourminuoftime = Formatter.format (time);

Formatter = new SimpleDateFormat ("Kk:mm:ss");

String Hourminusecofnow = Formatter.format (now);

Long Millisecofnow = Getmillisecofnow (Hourminusecofnow);

if ((now-millisecofnow<time) | | (Now-millisecofnow==time)) {
String timeofcurrentday = hourminuoftime;
string[] Hourandminute = Timeofcurrentday.split (":");
int hour =integer.parseint (hourandminute[0]);
Contentresolver CV = mcontext.getcontentresolver ();
String Strtimeformat = android.provider.Settings.System.getString (cv,android.provider.settings.system.time_12_24) ;
if (strtimeformat!=null) {
if (Strtimeformat.equals ("12")) {
if (hour>12) {
Return res.getstring (R.STRING.PM) +hour%12+ ":" +hourandminute[1];
Return res.getstring (r.string.am) +hour%12+ ":" +hourandminute[1];
Return hour%24+ ":" +hourandminute[1];
Return hour%24+ ":" +hourandminute[1];

if (now-518400000l-millisecofnow>time) {
return yearmonthday;
if (now-millisecofnow-86400000l<time) {
End:modified by Sunjinbiao in 20120823 for bug[540]
Return res.getstring (R.string.yesterday);

return DayOfWeek;

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.