JSP 后台部分代码不能运行 MVC模式下的开发

XX的小石头 XX的小石头 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我从前台传一个HH:mm格式的时间到这个方法里,代码运行到if(endtime1.getHours()>=begin.getHours()){之后就跳到flag=false那句了,这个判断条件是得到true的,是不是因为我定义的时间格式不相同的原因呢?求高手解答啊!!万分感谢!!

代码如下:

public boolean samedate(Place_user samedate) throws Exception {
// TODO Auto-generated method stub
boolean flag=false;
PreparedStatement psmt=null;
String placebegin=null;
Date begin=null;
SimpleDateFormat time1=new SimpleDateFormat("MM-dd,HH:mm");
SimpleDateFormat time2=new SimpleDateFormat("HH:mm");
//当前时间
String nowtime=time1.format(new Date());
Date nowtime1=time1.parse(nowtime);
//使用结束时间
String endtime=samedate.getEndtime();
Date endtime1=time2.parse(endtime);
String sql="select placebegin from place_date where placeno=?";
try{
psmt=this.conn.prepareStatement(sql);
psmt.setInt(1, samedate.getPlaceno());
ResultSet rs=psmt.executeQuery();
if(rs.next()){
placebegin=(rs.getString(1));
}
begin=time1.parse(placebegin);
//时间段判断
if( nowtime1.getDate()==begin.getDate()){
// if(endtime1.getHours()>=begin.getHours()){
// flag=true;
}else{
flag=false;

}
}
}catch(Exception e){
throw e;
}finally{
try{
psmt.close();
}catch(Exception e){
throw e;
}
}
return flag;
}
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
XX的小石头
Web 开发 81,108 成员 341,721 内容