此效果是 如果是今天以前的时间 界面只显示月日,如果是今天的时间 显示具体的时间 不显示年月
显示效果
具体实现功能
String dayTime=mSeemelist.get(
position)
.getTime();
// 当前时间
try {
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
//返回的是Date对象
Date date = dateFormat.parse(
dayTime);
//判断是否今天
if(
DateUtils.isToday(
date.getTime())){
//是今天
currentTime=dayTime.substring(
11,
16);
}
else {
//不是今天
SimpleDateFormat format = new SimpleDateFormat(
"MM-dd");
String str = format.format(
date);
//返回的str 03-08的格式
currentTime=dayTime.substring(
5,
11);
}
}
catch (
Exception e) {
e.printStackTrace();
}
转载请注明原文地址: https://ju.6miu.com/read-5639.html