Commit e468e1f8 authored by yanzg's avatar yanzg

默认日期格式的支持

parent 6775d890
...@@ -856,7 +856,8 @@ public class DateHelper { ...@@ -856,7 +856,8 @@ public class DateHelper {
} }
} }
private static final long HOUR_UNIT = 1000 * 60 * 15; private static final long MINUTE_UNIT = 1000 * 60;
private static final long HOUR_MINUTE_UNIT = 15;
/** /**
* 获取小时中的刻度时间 * 获取小时中的刻度时间
...@@ -865,14 +866,24 @@ public class DateHelper { ...@@ -865,14 +866,24 @@ public class DateHelper {
* @return * @return
*/ */
public static String getHourUnitTime(Object from) { public static String getHourUnitTime(Object from) {
return getHourUnitTime(from, HOUR_MINUTE_UNIT);
}
/**
* 获取小时中的刻度时间
*
* @param from 来源时间
* @return
*/
public static String getHourUnitTime(Object from, long minute) {
Date dateTime = getDateTime(from); Date dateTime = getDateTime(from);
if (dateTime == null) { if (dateTime == null) {
return null; return null;
} }
Date hour = DateHelper.getDateTime(DateHelper.getDateTimeString("yyyy-MM-dd HH:00:00.000", dateTime)); Date hour = DateHelper.getDateTime(DateHelper.getDateTimeString("yyyy-MM-dd HH:00:00.000", dateTime));
long totalMill = dateTime.getTime() - hour.getTime(); long totalMill = dateTime.getTime() - hour.getTime();
long unit = totalMill / HOUR_UNIT; long unit = totalMill / MINUTE_UNIT / minute;
Date to = new Date(hour.getTime() + unit * HOUR_UNIT); Date to = new Date(hour.getTime() + unit * MINUTE_UNIT * minute);
return DateHelper.getDateTimeString(to); return DateHelper.getDateTimeString(to);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment