我正在制定一项要求。我需要做的是从数据库中恢复最后的日期,增加它,然后检查一天是否是星期六。 我坚持的部分是如何检查第二天是否是星期六我正在使用primefaces 3.5 jsf2.1 apache tomcat 7.0.39
FacesContext context = FacesContext.getCurrentInstance();
Map requestMap = context.getExternalContext().getRequestParameterMap();
String value = (String) requestMap.get("id");
Integer id = Integer.parseInt(value);
SimpleDateFormat sdf= new SimpleDateFormat();
String sector=new String();
setFund(new Fund());
for(Map row:fund_grid){
Integer edit_id=(Integer.parseInt((String) row.get("fund_id")));
if(id.equals(edit_id)){
sector=(String) row.get("fund_sector_label");
mfp.setFund_id(Integer.parseInt( (String) row.get("fund_id")));
fund.setFund_id( (String) row.get("fund_id"));
setValidity_date(request_invoker.select_validity_date());
try {
Date ndate=sdf.parse((String) getValidity_date().get(0).get("validitydate"));
//日期在此处从数据库值15-11-2013退出
//现在递增一天
Calendar c = Calendar.getInstance();
c.setTime(ndate);
c.add(Calendar.DATE, 1);
fund.setNav_entry_date(c.getTime());
//这里是我被困的地方我不知道如何检查日期是否是星期六
if(fund.getNav_entry_date().equals(Calendar.SATURDAY))
{
c.add(Calendar.DATE, 2);
fund.setNav_entry_date(c.getTime());
}
else
{
fund.setNav_entry_date(c.getTime());
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
RequestContext context2 = RequestContext.getCurrentInstance();
if(sector.equals("open-end")){
context2.execute("opendialog.show();");
}
else if(sector.equals("close-end")){
context2.execute("closedialog.show();");
}
else if(sector.equals("pension")){
context2.execute("pensiondialog.show();");
}
}
任何非常感谢的帮助
答案 0 :(得分:2)
对bean进行了更改并且它正常工作日历c具有来自数据库的日期,而d具有当前日期。
Calendar c = Calendar.getInstance();
c.setTime(ndate);
Calendar d=Calendar.getInstance();
if(d.get(Calendar.DATE)==(c.get(Calendar.DATE)))
{
//message here
FacesMessage msg = new FacesMessage("NAV Upto Date" , "NAV Upto Date");
FacesContext.getCurrentInstance().addMessage(null, msg);
break;
}
else
{
c.add(Calendar.DATE, 1);
int day=c.SATURDAY;
int week=c.get(Calendar.DAY_OF_WEEK);
if(day==(week))
{
c.add(Calendar.DATE, 2);
fund.setNav_entry_date(c.getTime());
mfp.getDc().setValiditydate(c.getTime());
}
else
{
fund.setNav_entry_date(c.getTime());
mfp.getDc().setValiditydate(c.getTime());
}
RequestContext context2 = RequestContext.getCurrentInstance();
if(sector.equals("open-end")){
context2.execute("openenddialog.show();");
}
else if(sector.equals("close-end")){
context2.execute("closeenddialog.show();");
}
else if(sector.equals("pension")){
context2.execute("pensiondialog.show();");
}
}