Commit 7371b706 authored by yanzg's avatar yanzg

处理分页重复提示BUG

parent 060438f4
...@@ -62,22 +62,38 @@ public class DateHelper { ...@@ -62,22 +62,38 @@ public class DateHelper {
* 获取时间 * 获取时间
* *
* @param from 来源时间 * @param from 来源时间
* @param initMillSecond 是否初始化毫秒为0
* @return 结束时间 * @return 结束时间
*/ */
public static Date getDateTime(Object from) { public static Date getDateTime(Object from, boolean initMillSecond) {
if (StringHelper.isEmpty(from)) {
return null;
}
try { try {
Date to = null;
if (from instanceof Date) { if (from instanceof Date) {
return (Date) from; to = (Date) from;
} else if (from == null) { } else {
return null; to = DateAutoHelper.getAutoDate(String.valueOf(from));
} }
return DateAutoHelper.getAutoDate(String.valueOf(from)); to = initMillSecond(to);
return to;
} catch (Exception ex) { } catch (Exception ex) {
ExceptionHelper.handleException(DateHelper.class, ex, from); ExceptionHelper.handleException(DateHelper.class, ex, from);
} }
return null; return null;
} }
/**
* 获取时间,会自动初始化毫秒为0
*
* @param from 来源时间
* @return 结束时间
*/
public static Date getDateTime(Object from) {
return getDateTime(from, true);
}
/** /**
* Timestamp 转成 "yyyy-MM-dd HH:mm:ss"字符串 * Timestamp 转成 "yyyy-MM-dd HH:mm:ss"字符串
* *
......
package helper; package helper;
import com.yanzuoguang.util.helper.DateHelper; import com.yanzuoguang.util.helper.DateHelper;
import com.yanzuoguang.util.thread.ThreadHelper;
import org.junit.Test; import org.junit.Test;
import java.text.ParseException; import java.text.ParseException;
...@@ -23,4 +24,12 @@ public class TestDateHelper { ...@@ -23,4 +24,12 @@ public class TestDateHelper {
System.out.println("当前时间刻度:" + DateHelper.getHourUnitTime(new Date())); System.out.println("当前时间刻度:" + DateHelper.getHourUnitTime(new Date()));
} }
@Test
public void testDateHelper1() {
Date date = DateHelper.getDateTime("2010-1-1");
ThreadHelper.sleep(50);
Date date1 = DateHelper.getDateTime("2010-1-1");
System.out.println("日期转换时间是否相等:" + (date.getTime() == date1.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