Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date display

 
arjun rampal
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)
//Map dateMap = new HashMap();
Map dateMap = new TreeMap();
//List dateList = new ArrayList();
Calendar cal = Calendar.getInstance();

if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
{
cal.add(Calendar.DATE, -5);
for(int i = 1; i<=5; i++)
{
cal.add(Calendar.DATE, 1);
Date d = cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
dateMap.put(sdf.format(d), null);
}
}
else
{
cal.add(Calendar.DATE, -6);
for(int i=1; i<=6; i++)
{
if(cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY)
{
Date d = cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
dateMap.put(sdf.format(d), null);
}
cal.add(Calendar.DATE, 1);
}
}

System.err.println(dateMap.keySet());

if(iataData.size()> 0)
{
for(Iterator iterator = iataData.iterator(); iterator.hasNext()
{
IataAuditData iataAuditData = (IataAuditData)iterator.next();
Date d = iataAuditData.getAuditDate();
System.err.println(d.toString());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String key = sdf.format(d);
if(dateMap.containsKey(key))
{
System.out.println("Hurray");
dateMap.put(key, iataAuditData);
}
}

2)<td><logic resent name="element" property="value">
<bean efine id="iata" name="element" property="value"/>

<html:link action="/detailauditreport" paramName="iata" paramProperty="auditDate" paramId="adate">
<logic:equal name="iata" property="sunday" value="false" >
<bean:write name="iata" property="auditDate" formatKey="org.apache.struts.taglib.bean.format.date" />
</logic:equal></html:link></logic resent>

<logic:notPresent name="element" property="value">
0
</logic:notPresent>


Now expected functionality -action code will take the dates from daatabse and show it to jsp page in date coulmn for last five days and corrosponding data.
Now suppose in last five day if it does not have date for two days then it should show those dates(those missing dates are not in dataabse) and other data as 0

present functionality-but due to logic not present code it is showing 0.

Any idea?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic