|
|
@@ -215,7 +215,8 @@ public class DateUtils extends DateUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public static String numberDateFormat(String timestamp, String simpleDateFormatType) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat(simpleDateFormatType);//要转换的时间格式
|
|
|
+ //要转换的时间格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(simpleDateFormatType);
|
|
|
String date = null;
|
|
|
if (timestamp.length() == THIRTEEN) {
|
|
|
date = sdf.format(Long.parseLong(timestamp));
|
|
|
@@ -233,7 +234,8 @@ public class DateUtils extends DateUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public static Date numberDateFormatToDate(String timestamp, String simpleDateFormatType) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat(simpleDateFormatType);//要转换的时间格式
|
|
|
+ //要转换的时间格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(simpleDateFormatType);
|
|
|
Date date = null;
|
|
|
try {
|
|
|
if (timestamp.length() == THIRTEEN) {
|
|
|
@@ -271,12 +273,18 @@ public class DateUtils extends DateUtil {
|
|
|
* @Date: 2019/7/18 0018 16:46
|
|
|
*/
|
|
|
public static String getTimeBySecond(long seconds) {
|
|
|
- long days = seconds / 86400;//转换天数
|
|
|
- seconds = seconds % 86400;//剩余秒数
|
|
|
- long hours = seconds / 3600;//转换小时数
|
|
|
- seconds = seconds % 3600;//剩余秒数
|
|
|
- long minutes = seconds / 60;//转换分钟
|
|
|
- seconds = seconds % 60;//剩余秒数
|
|
|
+ //转换天数
|
|
|
+ long days = seconds / 86400;
|
|
|
+ //剩余秒数
|
|
|
+ seconds = seconds % 86400;
|
|
|
+ //转换小时数
|
|
|
+ long hours = seconds / 3600;
|
|
|
+ //剩余秒数
|
|
|
+ seconds = seconds % 3600;
|
|
|
+ //转换分钟
|
|
|
+ long minutes = seconds / 60;
|
|
|
+ //剩余秒数
|
|
|
+ seconds = seconds % 60;
|
|
|
if (0 < days) {
|
|
|
return days + "天," + hours + "小时," + minutes + "分," + seconds + "秒";
|
|
|
} else {
|
|
|
@@ -428,17 +436,22 @@ public class DateUtils extends DateUtil {
|
|
|
endCalendar.set(Calendar.DATE, 1);
|
|
|
endCalendar.roll(Calendar.DATE, -1);
|
|
|
if (day == (endCalendar.get(Calendar.DATE) - startCalendar.get(Calendar.DATE))) {
|
|
|
- monthCount = 1;// 两日期间满一个月
|
|
|
+ // 两日期间满一个月
|
|
|
+ monthCount = 1;
|
|
|
} else {
|
|
|
- monthCount = 0;// 两日期间不足一个月
|
|
|
+ // 两日期间不足一个月
|
|
|
+ monthCount = 0;
|
|
|
}
|
|
|
- } else if (year != 0 && month == 0) {// 年份不同月份相同
|
|
|
- if (startCalendar.get(Calendar.DATE) < endCalendar.get(Calendar.DATE)) {// 两日期间的天数,小于等于当月
|
|
|
+ // 年份不同月份相同
|
|
|
+ } else if (year != 0 && month == 0) {
|
|
|
+ // 两日期间的天数,小于等于当月
|
|
|
+ if (startCalendar.get(Calendar.DATE) < endCalendar.get(Calendar.DATE)) {
|
|
|
monthCount = 1;
|
|
|
}
|
|
|
monthCount += year * 12 + month;
|
|
|
} else {
|
|
|
- if (startCalendar.get(Calendar.DATE) >= endCalendar.get(Calendar.DATE)) {// 起始日期DATE 大于等于结束日期DATE
|
|
|
+ // 起始日期DATE 大于等于结束日期DATE
|
|
|
+ if (startCalendar.get(Calendar.DATE) >= endCalendar.get(Calendar.DATE)) {
|
|
|
monthCount = year * 12 + month;
|
|
|
} else {
|
|
|
monthCount = year * 12 + month + 1;
|