Commit c5cb6727 authored by yanzg's avatar yanzg

修改实体位置

parent fd8f53b9
...@@ -891,4 +891,29 @@ public class DateHelper { ...@@ -891,4 +891,29 @@ public class DateHelper {
// 将时间转换为字符串 // 将时间转换为字符串
return DateHelper.getDateTimeString(to); return DateHelper.getDateTimeString(to);
} }
/**
* 获取小时中的刻度时间
*
* @param from 来源时间
* @return
*/
public static int getMonthBetween(Object from, Object to) {
Date fromDate = getDateTime(from);
Date toDate = getDateTime(to);
if (from == null || toDate == null) {
return 0;
}
Calendar bef = Calendar.getInstance();
bef.setTime(fromDate);
Calendar aft = Calendar.getInstance();
aft.setTime(getDateTime(toDate));
int surplus = aft.get(Calendar.DATE) - bef.get(Calendar.DATE);
int result = aft.get(Calendar.MONTH) - bef.get(Calendar.MONTH);
int month = (aft.get(Calendar.YEAR) - bef.get(Calendar.YEAR)) * 12;
surplus = surplus <= 0 ? 1 : 0;
return (Math.abs(month + result) + surplus);
}
} }
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