时间快到了,提前5天预警提示。怎么做?

来源:百度知道 编辑:UC知道 时间:2024/05/28 17:29:05
预警天数(yjts)-(当前时间(time)-开票时间(kpsj))< 5
系统有个提示。
怎么做?给出代码谢谢!
yjts、kpsj都是数据库直接掉出来的。
而当前时间是系统时间直接读的。
JSP+MSSQL
<%@ page import="java.text.*" %>
<%
String time = "";
SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
time = dformat.format(new java.util.Date());
time = time.replaceAll("-","");
time = time.replaceAll(" ","");
time = time.substring(0,12);
%>

希望大虾帮忙下谢谢!

方法肯定很多,我随便写个
Calendar rightNow = Calendar.getInstance(); //你的当前时间
Calendar time = Calendar.getInstance();
time.setTime(yjts); //把time这个Calendar时间置为你取出的日期
rightNow.getTimeInMillis() //这个是当前时间转毫秒数
time.getTimeInMillis() //....
上面两个东西减一下小于24*60*60*1000就是控制差距在一天内
其他的依次类推

不太懂你说的是什么 东西

select * from 日程安排 where datediff('day',f开始时间,getdate())>5