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];
}else{
Return res.getstring (r.string.am) +hour%12+ ":" +hourandminute[1];
}
}else{
Return hour%24+ ":" +hourandminute[1];
}
}else{
Return hour%24+ ":" +hourandminute[1];
}
}else{
if (now-518400000l-millisecofnow>time) {
return yearmonthday;
}else{
if (now-millisecofnow-86400000l<time) {
End:modified by Sunjinbiao in 20120823 for bug[540]
Return res.getstring (R.string.yesterday);
}else{
return DayOfWeek;
}
}
}
}