String KaiTaiShiJian = "";
long hours = 0;//小时
long fz = 0;//分钟
if (null != v[13]) {
//当前时间
Date date = new Date();
String formatStr = "";
Date asd = null;
KaiTaiShiJian = v[13].toString();
String df = new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(date);
try {
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
asd = (Date) sdf.parse(KaiTaiShiJian);
formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(asd);
logger.info(formatStr);
} catch (Exception e) {
e.printStackTrace();
}
long diff = date.getTime() - asd.getTime();
long min = 0;//分钟
long day = 0;
long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
long nh = 1000 * 60 * 60;// 一小时的毫秒数
long nm = 1000 * 60;// 一分钟的毫秒数
day = diff / nd;// 计算差多少天
min = diff % nd % nh / nm + day * 24 * 60;// 计算差多少分钟
//小时
hours = diff / 60 / 60 / 1000;
//分钟
fz = min - day * 24 * 60;
}
int xs= Integer.valueOf((int) hours);
int fenz= Integer.valueOf((int) fz);
Format formatCount = new DecimalFormat("00");
String shi = formatCount.format(xs);
String fen = formatCount.format(fenz);
01-26
416
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)