Commit 528d85af by 陶光胜

取数平台权限

parent 219ad39a
...@@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -65,7 +67,7 @@ public class AlarmController { ...@@ -65,7 +67,7 @@ public class AlarmController {
alarmTime = calendar.getTime(); alarmTime = calendar.getTime();
if(alarmTime.before(new Date())){ if(alarmTime.before(new Date())){
result.put("type", 1); result.put("type", 1);
result.put("remain", (alarmTime.getTime() - new Date().getTime())/1000/3600/24); result.put("remain", getDays(expireTime));
}else { }else {
result.put("type", 0); result.put("type", 0);
result.put("remain", 0); result.put("remain", 0);
...@@ -77,4 +79,17 @@ public class AlarmController { ...@@ -77,4 +79,17 @@ public class AlarmController {
} }
return result; return result;
} }
private long getDays(Date expireTime){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = dateFormat.parse(dateFormat.format(expireTime));
Date now = dateFormat.parse(dateFormat.format(new Date()));
long l = (date.getTime() - now.getTime()) / 3600 / 24 / 1000;
return l;
} catch (ParseException e) {
e.printStackTrace();
}
return 0;
}
} }
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