|
@@ -1,10 +1,13 @@
|
|
|
package api.common.util;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.TimeZone;
|
|
|
|
|
|
public class TimeUtil {
|
|
|
|
|
|
+ private static String[] dateFmtArr= new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss","yyyy-MM-dd"};
|
|
|
|
|
|
public static long getNow() {
|
|
|
return System.currentTimeMillis();
|
|
@@ -16,5 +19,14 @@ public class TimeUtil {
|
|
|
|
|
|
public static long zeroOfToday() {
|
|
|
return System.currentTimeMillis() / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();
|
|
|
+ }
|
|
|
+ //获取时间类型格式转化
|
|
|
+ public static Integer getRq(Date date, int index){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(dateFmtArr[index]);
|
|
|
+ if(date == null){
|
|
|
+ date = new Date();
|
|
|
+ }
|
|
|
+ return Integer.valueOf(sdf.format(date));
|
|
|
+
|
|
|
}
|
|
|
}
|