Commit 816e306a authored by yanzg's avatar yanzg

升级新版本

parent 1edc95d9
......@@ -24,6 +24,9 @@ public class DateHelper {
public static final String INIT_TIME = "00:00:00";
public static final String FORMAT_DAY_HOUR_STRING = "yyyy-MM-dd HH:00:00";
public static final String FORMAT_SECOND_STRING = "yyyy-MM-dd HH:mm:ss";
public static final int INIT_MILL_SECOND_NONE = 0;
public static final int INIT_MILL_SECOND_START = 1;
public static final int INIT_MILL_SECOND_END = 2;
private static final int MONTH_1 = 1;
private static final int MONTH_2 = 2;
......@@ -80,19 +83,21 @@ public class DateHelper {
* @param initMillSecond 是否初始化毫秒为0
* @return 结束时间
*/
public static Date getDateTime(Object from, boolean initMillSecond) {
public static Date getDateTime(Object from, int initMillSecond) {
if (StringHelper.isEmpty(from)) {
return null;
}
try {
Date to = null;
Date to;
if (from instanceof Date) {
to = (Date) from;
} else {
to = DateAutoHelper.getAutoDate(String.valueOf(from));
}
to = initMillSecond(to);
return to;
if (initMillSecond == INIT_MILL_SECOND_NONE) {
return to;
}
return initMillSecond(to, initMillSecond);
} catch (Exception ex) {
ExceptionHelper.handleException(DateHelper.class, ex, from);
}
......@@ -124,7 +129,7 @@ public class DateHelper {
* @return 结束时间
*/
public static Date getDateTime(Object from) {
return getDateTime(from, true);
return getDateTime(from, INIT_MILL_SECOND_NONE);
}
/**
......@@ -302,13 +307,21 @@ public class DateHelper {
/**
* 获取当天的日期
*
* @param date 需要的日期
* @param date 需要的日期
* @param initMillSecond 初始化毫秒单位
* @return 返回的日期
*/
public static Date initMillSecond(Date date) {
public static Date initMillSecond(Date date, int initMillSecond) {
if (initMillSecond == INIT_MILL_SECOND_NONE) {
return date;
}
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.MILLISECOND, 0);
if (initMillSecond == INIT_MILL_SECOND_START) {
c.set(Calendar.MILLISECOND, 0);
} else {
c.set(Calendar.MILLISECOND, 999);
}
return c.getTime();
}
......
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