1. List 由 findAll 取出
List 中的 date 类型visitTime1
前台jsp 类型转换
String visitTime1 = people.getVisitTime()== null ? ""
: DateUtil.dateToString(people.getVisitTime(), "MM-dd HH:mm");
2.input 隐藏边框 样式 style="border-style:none"
3新建数据库表时 id标识 选 “ 是 ” id 设置主键
4 String 类型转换成 Date 类型
Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date visitTime = null;
try {
if (visitTime != null) {
visitTime= = format.parse(request.getParameter("visitTime"));
} else {
visitTime = curDate;
}
5.。获取时间 时间相减
String searchDay;
String newDay;
String oldDay1;
Date curDate1 = new Date();// 获取当前时间
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
People people1 = peopleService.findById(di);
Date oldDay = null;
try {
if(people1.getVisitTime()!=null){
oldDay = people1.getVisitTime();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
oldDay1=DateUtil.dateToString(oldDay,"yyyy-MM-dd");
String newday2 =DateUtil.dateToString(curDate1,"yyyy-MM-dd");
int dd =newday2.compareTo(oldDay1);
System.out.println("======ddddd===="+dd);
searchDay=dd+"";
//System.out.println("*****************=="+searchDay);
people.setSearchDay(searchDay);
6.model 中的属性 首字母不能大写, 如name不能写成Name
7.No action config found for the specified url.
是因为 Struts .xml中没有对应的action名字
有的时候乱码 tomcat 引起
在tomcat conf/server.xml 中加入 <Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="GBK" />
long 时间 转换
if(searchItem.equals("nday")||searchItem.equals("creat_time")){
int londayInt = (int)Long.parseLong(searchValue);
Calendar cal = Calendar.getInstance(); //使用默认时区和语言环境获得一个日历。 // System.out.println("londayInt#################==="+londayInt);
cal.add(Calendar.DAY_OF_MONTH, - londayInt); //取当前日期的前一天. // System.out.println(caldate);
// String caldate =DateUtil.dateToString( cal.getTime(), "yyyy-MM-dd");
String caldate =DateUtil.dateToString( cal.getTime(), "yyyy-MM-dd");
System.out.println("cal.getTime()======"+cal.getTime());
StringBuffer strbuf = new StringBuffer();
for(int i=0;i<peoplelis.size();i++){
peoplelis.get(i).getNday();
if(searchItem.equals("creat_time")&&peoplelis.get(i).getNday()==null){
searchItem="creat_time";
strbuf.append(searchItem);
}
}
if(!strbuf.equals("")&&strbuf.length()>0){
String strbufStr=strbuf.substring(0, 10);
System.out.println("strbufStr======"+strbufStr);
searchItem=strbufStr;
sadd=" and nday is null ";
}
searchValue=caldate;
);
}
7,获取当前时间 的前一天
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -1);
String yestedayDate= new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
8.取小数点后两位
java.text.DecimalFormat df=new java.text.DecimalFormat("#.##");
out.print("余额总数 :"+df.format(zongshu));