•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 426,477 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,225 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1084 | Replies: 4
![]() |
•
•
Join Date: Jul 2007
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
Date dnow = new java.util.Date();
int iMonth = Integer.parseInt(DateEx.dateToStringFormat(dnow,"MM"));
int iYear = Integer.parseInt(DateEx.dateToStringFormat(dnow,"YYYY"));
int iDay = Integer.parseInt(DateEx.dateToStringFormat(dnow,"DD"));
int iWeek = 0;
Calendar cWeek = Calendar.getInstance();
if (request.getParameter("cweek") != null) {
iWeek = Integer.parseInt(request.getParameter("cweek"));
} else {
cWeek.set(iYear, iMonth+1, iDay);
iWeek = cWeek.get(cWeek.WEEK_OF_MONTH);
cWeek.set(iYear, iMonth+1, 1);
if (cWeek.get(cWeek.DAY_OF_WEEK) != 1) {
iWeek = iWeek - 1;
}
}
if (iWeek==0)
iWeek=1;
String strMonth = null;
String strYear = null;
String strFP = null;
Date dFDay = null;
Date dLDay = null;
Date dend = null;
int curYear = 0;
int curMonth = 0;
int iSDate = 1;
int iFDate = 1;
ArrayList[] aL = new ArrayList[32];
try {
if (page.get("query") != null) { //Search
curMonth = Integer.parseInt(page.get("sMonth"));
curYear = Integer.parseInt(page.get("sYear"));
iWeek=1;
scheduleDet = new FPSScheduleDetail();
if (page.get("FPCode") != null) {
scheduleDet.sFPCode = page.get("FPCode");
} else {
if (request.getParameter("fpcode") != null)
scheduleDet.sFPCode = request.getParameter("fpcode");
}
} else {
if (request.getParameter("cyear") != null) {
curYear = Integer.parseInt(request.getParameter("cyear"));
} else {
curYear = iYear;
}
if (request.getParameter("cmonth") != null) {
curMonth = Integer.parseInt(request.getParameter("cmonth"));
} else {
curMonth = iMonth;
}
scheduleDet = new FPSScheduleDetail();
scheduleDet.sFPCode = page.get("FPCode");
if (request.getParameter("fpcode") != null)
scheduleDet.sFPCode = request.getParameter("fpcode");
}
if (iWeek != 0){
//scheduleDet = new FPSScheduleDetail();
//scheduleDet.sFPCode = page.get("FPCode");
if (scheduleDet.sFPCode == null)
scheduleDet.sFPCode = secu.getFpCode();
//if (request.getParameter("fpcode") != null)
// scheduleDet.sFPCode = request.getParameter("fpcode");
strMonth = Integer.toString(curMonth);
strYear = Integer.toString(curYear);
iYear = curYear;
iMonth = curMonth;
dend = DateEx.endMonthDate(iYear,iMonth);
Calendar cDay = Calendar.getInstance();
for (int i = 1; i < 32; i++) {
cDay.set(iYear, iMonth - 1, i);
if (cDay.get(cDay.DAY_OF_WEEK) == 1) {
iSDate = i;
iFDate = i;
break;
}
}
iSDate = 1;
iFDate = 1;
iSDate = iSDate + ((iWeek - 1) * 7);
cDay.set(iYear, iMonth-1, iSDate);
cDay.add(cDay.DATE, +7);
dFDay = DateEx.stringToDateTime(Integer.toString(iSDate) + "/" + strMonth + "/" + strYear + " 00:00");
dLDay = DateEx.stringToDateTime(cDay.get(cDay.DATE) + "/" + (cDay.get(cDay.MONTH)+1) + "/" + cDay.get(cDay.YEAR) + " 00:00");
}
} catch(Exception ex) {
page.writeErr(ex);
}
page.print("<TABLE><TR>");
page.print("<TD CLASS='xtd'>Submenu : > </TD>");
//page.print("<TD CLASS='xtd'><A HREF='wschdlr?miid=" + miid + "'> Weekly Schedule </TD>");
page.print("<TD CLASS='xtd'><A HREF='mschdlr?miid=" + miid + "&fpcode=" + scheduleDet.sFPCode +"'> Monthly Schedule </TD>");
page.print("</TR></TABLE>");
page.print("<BR>");
page.print("<FORM name='Schedule' action='wschdlr' method=POST>");
RefCodeInfo[] refInfo = null;
RefCodeInfo[] apptInfo = bizRef.getAPPT(sLang);
if (request.getParameter("midd") != null) {
miid = request.getParameter("midd");
}
if (miid.equalsIgnoreCase(pageid[0])) {
refInfo = new RefCodeInfo[1];
refInfo[0] = new RefCodeInfo();
refInfo[0].sRefCode = secu.getFpCode();
refInfo[0].sRefCodeDesc = refInfo[0].sRefCode + " - " + dbFP.getFPName(refInfo[0].sRefCode);
} else if (miid.equalsIgnoreCase(pageid[1])) {
FPStructureInfo[] stucInfo = dbFP.getFPDownline(secu.getFpCode());
if (stucInfo != null) {
refInfo = new RefCodeInfo[stucInfo.length + 1];
for (int i = 0; i <= stucInfo.length; i++) {
refInfo[i] = new RefCodeInfo();
if (i == 0) {
refInfo[i].sRefCode = secu.getFpCode();
refInfo[i].sRefCodeDesc = refInfo[i].sRefCode + " - " + dbFP.getFPName(refInfo[i].sRefCode);
continue;
}
refInfo[i].sRefCode = stucInfo[i - 1].sFPCode;
refInfo[i].sRefCodeDesc = stucInfo[i - 1].sFPCode + " - " + dbFP.getFPName(stucInfo[i - 1].sFPCode);
}
}
} else if (miid.equalsIgnoreCase(pageid[2])) {
FinancialPlannerInfo[] fpInfo = dbFP.getAllFP();
if (fpInfo != null) {
refInfo = new RefCodeInfo[fpInfo.length];
for (int i = 0; i < fpInfo.length; i++) {
refInfo[i] = new RefCodeInfo();
refInfo[i].sRefCode = fpInfo[i].sFPCode;
refInfo[i].sRefCodeDesc = fpInfo[i].sFPCode + " - " + fpInfo[i].sFPName;
}
}
}
page.print("<TABLE><TR>");
page.print("<TD CLASS='xtd'>" + dbutil.getLabel(conmgr.env.getUserId(), "FPSSCHEDULE.FPCODE") + "</TD>");
page.print("<TD CLASS='xtd'>" + htmlutil.printDropDownRefCode("FPCode", refInfo, scheduleDet.sFPCode, true, false, true, true, false) + "   </TD>");
page.print("<TD CLASS='xtd'>" + dbutil.getLabel(conmgr.env.getUserId(), "ENQUIRY.YEAR") + "</TD>");
page.print("<TD CLASS='xtd'>" + htmlutil.printTextBox("sYear", Integer.toString(iYear), 4, 4) + "  </TD>");
page.print("<TD CLASS='xtd'>" + dbutil.getLabel(conmgr.env.getUserId(), "ENQUIRY.MONTH") + "</TD>");
//page.print("<TD CLASS='xtd'>" + htmlutil.printTextBox("sMonth", Integer.toString(iMonth), 2, 2) + "  </TD>");
RefCodeInfo[] refMonth = null;
refMonth = new RefCodeInfo[12];
String sLM = null;
sLM = Integer.toString(iMonth);
if (sLM.length() == 1)
sLM = "0" + sLM;
page.print("<TD CLASS='xtd'>" + html.printDropDownMonth("sMonth", refMonth, sLM, true, false, false, true, true) + "  </TD>");
page.print("<TD CLASS='xtd'><INPUT TYPE=SUBMIT NAME='query' VALUE=" + dbutil.getLabelOnly(conmgr.env.getUserId(), "B_ENQUIRY") + ">   " + dbutil.getLabel(conmgr.env.getUserId(), "FPSSCHEDULE.WEEK") + "  </TD>");
if (scheduleDet.sFPCode == null) {
strFP = request.getParameter("fpcode");
} else {
strFP = scheduleDet.sFPCode;
}
iFDate = iFDate + (4 * 7);
int daysinMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (((iYear % 4) == 0) && (((iYear % 100) != 0) || ((iYear % 400) == 0)))
daysinMonth[1] = 29;
for (int i = 1; i < 6; i++) {
page.print("<TD CLASS='xtd'>");
if (i==5 && iFDate > daysinMonth[iMonth - 1]) {
} else {
if (i != iWeek) {
page.print("<TD CLASS='xtd'><A HREF='wschdlr?cmonth="+ curMonth + "&cyear=" + curYear + "&cweek=" + i + "&miid=" + miid +"&fpcode=" + strFP +"'>" + i + "</A></TD>");
} else {
page.print("<TD CLASS='xtd'>" + i + "</TD>");
}
}
page.print("</TD>");
}
page.print("</TR></TABLE>");
page.print(html.printHiddenField("miid", miid));
page.print(html.printHiddenField("fpcode", scheduleDet.sFPCode));
page.print("</FORM>");
schdDet = dbSchedule.getScheduleByFP(strFP, dFDay, dLDay);
int iACount = Integer.parseInt(DateEx.dateToStringFormat(dFDay,"DD"));
int iDate = 0;
for (int i2 = 0; i2 < 32; i2++) {
if(aL[i2] == null)
aL[i2] = new ArrayList();
}
if (schdDet != null) {
for (int i = 0; i < schdDet.length; i++) {
//for (int i2 = iACount; i2 < iACount + 7; i2++) {
for (int i2 = 1; i2 < 32; i2++) {
Calendar cl = Calendar.getInstance();
cl.setTime(schdDet[i].dtApptDateTime);
iDate = cl.get(Calendar.DAY_OF_MONTH);
if(iDate == i2) {
aL[i2].add(schdDet[i]);
}
}
}
}
//show calendar
SimpleDateFormat sd1 = new SimpleDateFormat("MMMMM");
page.print("<CENTER>");
page.print("<FORM NAME='fweek' ACTION='wschdlr' METHOD=POST>");
page.print("<TABLE CELLPADDING='3' CELLSPACING='0' WIDTH='95%' BORDER='2' BGCOLOR='FFFFFF'>");
page.print("<TR VALIGN='MIDDLE' ALIGN='CENTER'>");
page.print("<TD COLSPAN='7'>");
page.print("<TABLE CELLPADDING='0' CELLSPACING='0' WIDTH='100%' BORDER='0'>");
page.print("<TR VALIGN='MIDDLE' ALIGN='CENTER'>");
page.print("<TH WIDTH='100%' CLASS='xtd2'>" + dbutil.getLabel(conmgr.env.getUserId(), "FPSSCHEDULE.WEEK") + " " + iWeek + "   " + sd1.format(dend) + " " + curYear + "</TH>");
page.print("</TR></TABLE></TD></TR>");
//start print details
page.print("<TR VALIGN='TOP' ALIGN='CENTER' BGCOLOR='FFFFFF'>");
SimpleDateFormat sd = new SimpleDateFormat("EEEEE");
Calendar c = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
for (int iDay2 = 1; iDay2 < 8; iDay2++) {
//c.set(Calendar.DAY_OF_WEEK,iDay2);
c.set(c.get(c.YEAR), dend.getMonth(), iDay2);
page.print("<TD WIDTH='14%' CLASS='xtd'>"+ sd.format(c.getTime()) + "<BR>");
c2.set(iYear, iMonth-1, Integer.parseInt(DateEx.dateToStringFormat(dFDay,"DD")));
c2.add(c2.DATE, + (iDay2-1));
//page.print("(" + c2.get(c2.DATE) + "/" + (c2.get(c2.MONTH)+1) + "/" + c2.get(c2.YEAR) + ")" + "</TH>");
//page.print("<A HREF='feschdlr?miid=11005&mode=2&reload=&ApptDate="+ c2.get(c2.DATE) + "/" + (c2.get(c2.MONTH)+1) + "/" + c2.get(c2.YEAR) +"&FPCode="+ strFP +"'>" + "(" + c2.get(c2.DATE) + "/" + (c2.get(c2.MONTH)+1) + "/" + c2.get(c2.YEAR) + ")" + "</A></TD>");
page.print("<A HREF='feschdlr?miid=11005&ApptDate="+ c2.get(c2.DATE) + "/" + (c2.get(c2.MONTH)+1) + "/" + c2.get(c2.YEAR) +"'>" + "(" + c2.get(c2.DATE) + "/" + (c2.get(c2.MONTH)+1) + "/" + c2.get(c2.YEAR) + ")" + "</A></TD>");
}
page.print("</TR>");
int iC1 = 0;
int iC2 = 0;
for (int iC=iACount; iC < iACount + 7; iC++) {
page.print("<TD WIDTH='14%' HEIGHT='100' VALIGN='TOP' ALIGN='LEFT' CLASS='xtd'><BR>");
page.print("<TABLE CELLPADDING='0' CELLSPACING='0' WIDTH='100%' BORDER='0' BGCOLOR='FFFFFF'>");
if (iC > daysinMonth[iMonth - 1]) {
iC2 = iC2 + 1;
iC1 = iC2;
} else {
iC1 = iC;
}
if (! aL[iC1].isEmpty()) {
for (int iSDet=0; iSDet < aL[iC1].size(); iSDet++) {
FPSScheduleDetail a = (FPSScheduleDetail)aL[iC1].get(iSDet);
page.print("<TR>");
//page.print("<TD CLASS='xtd3'><A HREF='feschdlr?miid=11005&mode=2&ApptId="+ a.sApptId +"'>" + "<BR>" + DateEx.dateToStringFormat(a.dtApptDateTime,"HH:NN") + "<BR>" + dbClient.getClientName(a.sClientNo) + "<BR>" + a.sApptCode + "</A></TD>");
page.print("<TD CLASS='xtd3'><A HREF='feschdlr?miid=11005&mode=2&ApptId="+ a.sApptId +"'>");
page.print("<FONT SIZE='5'>" + DateEx.dateToStringFormat(a.dtApptDateTime,"HH:NN") + " - " + DateEx.dateToStringFormat(a.dtApptDateEnd,"HH:NN") + "</FONT>");
if (cv.isMandatory(a.sClientNo))
page.print("<BR>" + dbClient.getClientName(a.sClientNo) + "<BR>" + LookUpUtil.codeToDesc(apptInfo, a.sApptCode));
else
page.print("<BR> NOT ASSIGN <BR>" + LookUpUtil.codeToDesc(apptInfo, a.sApptCode));
if (a.sRstDesc != null)
page.print("<BR>" + a.sRstDesc + "<BR>");
if (a.sRemarks != null)
page.print("<BR>" + a.sRemarks + "<BR>");
page.print("<BR><BR><BR><BR></A></TD></TR>");
}
}
page.print("</TABLE>");
page.print("</TD>");
}
page.print(html.printHiddenField("miid", miid));
page.print("</TABLE></FORM>");
page.print("</CENTER>");and also in dropdownlist it showing same month twice
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,458
Reputation:
Rep Power: 11
Solved Threads: 296
What an old book/resources you using???
Didn't see anybody for long time to write JSP as you
Didn't see anybody for long time to write JSP as you
page.print("<TABLE><TR>");, also many methods and some Date constructors has been deprecated and are not used any more. I would recommend to use Calendar or even better GregorianCalendar. If you have instalation of tomcat in JSP examples you can find Date example or can check it here, also there is nice tutorial site with examples on how to date and time Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Well, this code is fairly bad, I'm sorry, I don't mean to be offensive, I'm just stating the way it is, but for a quick fix try this.
You are currently doing this
which is essentially cycling through an array of days organized as
So, think about it. What do you need to do to change the order of days you are interested in?
Setup an array in the order you want it (the days should still be in the proper order of course) and use that array in the for loop.
Like this:
You are currently doing this
for (int iDay2 = 1; iDay2 < 8; iDay2++) {{ Calendar.SUNDAY, Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY, Calendar.SATURDAY }Setup an array in the order you want it (the days should still be in the proper order of course) and use that array in the for loop.
Like this:
int[] days = { Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY, Calendar.SATURDAY, Calendar.SUNDAY };
for (int dayIndex = 0; dayIndex < days.length; dayIndex++) {
int iDay2 = days[dayIndex]; Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Ms Access 2003-How do I put a calender inside a form so user can pick date from month (MS Access and FileMaker Pro)
- Outlook 2000 calendar: all-day event problem (Windows Software)
- Calender printing (Java)
- How long do you use your computer each day? (Geeks' Lounge)
Other Threads in the JSP Forum
- Previous Thread: cant get an applet in jsp
- Next Thread: getting values from drop down menu



Linear Mode