Note that there are some explanatory texts on larger screens.

plurals
  1. POJava help comparing Calendar objects
    primarykey
    data
    text
    <p>I have developed a Calendar widget in Java (for BlackBerry development, specifically). A user can view all of the days in a current month, as well as move forward/backward in months/years.</p> <p>When I draw my calendar (in a table format), I want to change the color of any days that are X days in advance of the current date. I can currently check for this ONLY if the calendar shown on the screen is the same month as the current month:</p> <pre><code> if (calendarMonth == currentMonth) { for (int i = 1; i &lt;= (NUM_DAYS_IN_MONTH); i++) { if (i &gt; currentDay + Constants.CALENDAR_DAYS_IN_ADVANCE) { System.out.println("VALID: " + i); } } } </code></pre> <p>But I am having trouble coding a solution for when the calendar shown is a different month from the current month. For example, today is January 26th, so the January calendar will show all of the January days as a grey color. When the user changes the month to February, then the following days should be grey:</p> <pre><code>Constants.CALENDAR_DAYS_IN_ADVANCE = 14; 1/26/2011 - 2/9/2011 </code></pre> <p>Any days past that range will be a black color. So basically, I am looking to write a function that will accept two java.util.Calendar objects (the active calendar shown and a calendar for the current date), and the function will return an array of dates in the range of CURRENT DATE - CALENDAR_DAYS_IN_ADVANCE.</p> <p>I also need to keep in mind the following:</p> <p>1) I cannot compare dates with the java.util.Calendar.add() or java.util.Calendar.subtract() functions, as java for BlackBerry is limited</p> <p>2) This has to work across years, too, for example December 2010 - January 2011</p> <p>Can anybody help with the logic?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload