public boolean getDateMatches(String date){
try {
query="select * from "+TABLE_NAME+" "
+ "where "+MATCH_DATE+"='"+date+"';";
pst=con.prepareStatement(query);
rs=pst.executeQuery();
while(rs.next()){
matchNos.add(rs.getInt(MATCH_NO));//array list of Integers
homeTeams.add(rs.getString(HOME_TEAM));
awayteams.add(rs.getString(AWAY_TEAM));
matchTimes.add(rs.getString(MATCH_TIME));
matchDates.add(rs.getString(MATCH_DATE));
}
flag=true;
} catch (SQLException ex) {
flag=false;
}
finally{
return flag;
}
}
//Function to get date after given number of days
public static String getDate(int days){
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
Date date=new Date();
Calendar c=Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, days);
return sdf.format(c.getTime()).toString();
}
第一个是我用来从数据库中检索值的函数,当我以字符串格式传递日期时它工作正常,但是当我使用 getDate() 从系统检索日期并将日期传递给第一个函数时,没有值被存储在matchNos,主队,客队,比赛时间和比赛日期
注意:第二个函数返回正确的值
请提出解决方案提前谢谢