仿iphone中短信/通话记录的时间显示
2012-10-31 20:20
330 查看
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 on 20120823 for bug[540]
return res.getString(R.string.yesterday);
}else{
return dayOfWeek;
}
}
}
}
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 on 20120823 for bug[540]
return res.getString(R.string.yesterday);
}else{
return dayOfWeek;
}
}
}
}
相关文章推荐
- 仿iphone中短信以及通话记录的时间显示
- 俄语通话记录时间显示问题
- 一款基于C#开发的WPF可以在放映PPT时记录放映时间,并显示当前页数
- 获取通讯录、通话记录、短信
- Android通讯录管理(获取联系人、通话记录、短信消息)
- android 使用内容提供者 获取通话记录 短信
- history查看历史操作记录,并显示操作时间
- android实习程序7——通话记录显示
- 记录并显示网页的最后修改时间 收藏
- 安卓手机不开机的情况下 怎么备份 联系人 短信 通话记录
- 创建一张表,记录电话呼叫员的工作流水,记录呼叫员编 号、对方号码、通话开始时间、通话结束时间。建表、插数 据等最后都自己写SQL语句。
- 安卓手机短信、通话记录、通信录删除了怎么恢复
- Android编程之短信列表的时间显示实例分析
- 如何让linux的history命令显示时间记录
- 安卓手机不能开机 怎么备份 联系人 短信 通话记录
- android: 用ContentResolver读取自己应用的短信和手机通话记录(15)
- 宿主手机联系人、通话记录、短信工具类(不断完善中。。。)
- android 视频通话开启呼叫等待后,来第三方的视频通话,接通后通话时间一直显示为0,过几秒之后视频通话自动挂断
- Android通话记录ListView实现左滑发短信和右滑打电话
- 根据ajax从服务器获取数据的时间和ID,根据最近的时间,显示一个记录重复ID的数字