将秒数转换为日时分秒,
/** * 获取剩余时间 * * @return */ public static String getRemainingTime(String createTime, int expriedDays) throws ParseException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = format.parse(createTime); Long createMill = date.getTime() / 1000; Long expirationMill = expriedDays * 24 * 60 * 60l; Long t = Long.valueOf(getDateline()); Long time = createMill + expirationMill - t; return secondToTime(time); } /** * 将秒数转换为日时分秒, * * @param second * @return */ public static String secondToTime(long second) { long days = second / 86400; //转换天数 second = second % 86400; //剩余秒数 long hours = second / 3600; //转换小时 second = second % 3600; //剩余秒数 long minutes = second / 60; //转换分钟 second = second % 60; //剩余秒数 if (days > 0) { return days + "天" + hours + "小时" + minutes + "分" + second + "秒"; } else { return hours + "小时" + minutes + "分" + second + "秒"; } }