RSS Forums RSS
Please support our JSP advertiser: Lunarpages JSP Web Hosting

day in a calender

Join Date: Feb 2006
Posts: 1,565
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 11
Solved Threads: 144
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: day in a calender

  #5  
Jul 31st, 2007
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
for (int iDay2 = 1; iDay2 < 8; iDay2++) {
which is essentially cycling through an array of days organized as
{ Calendar.SUNDAY, Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY, Calendar.SATURDAY }
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:
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
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 7:04 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC