I seem to have resolved it b y replacing the call to the method after
with a comparison.
Thanks everyone!


On Dec 12, 12:13 pm, andrew android <[email protected]> wrote:
> the code is something like this...
>
> public void getWorkDays(final int mm,  final int dd,final int ccyy,
>                         final int mmNew, final int ddNew, final int ccyyNew) {
>
>                 Calendar c2 = Calendar.getInstance();
>                 Calendar c4 = Calendar.getInstance();
>
>                 c2.set(ccyy, mm, dd);
>                 c4.set(ccyyNew,mmNew, ddNew);
>                 c2.setFirstDayOfWeek(1);
>                 c4.setFirstDayOfWeek(1);
>
>                 Integer counter = 0;
>
>                 while (c4.after(c2)) {
>
>                         switch (c2.get(Calendar.DAY_OF_WEEK)){
>                         case 1:
>
>                                         c2.add(Calendar.DATE, 1);
>                                         break;
>                         case 2:
>
>                                         counter = counter + 1;
>                                 c2.add(Calendar.DATE, 1);
>                                 break;
>                         case 3:
>                                         counter = counter + 1;
>
>                                 c2.add(Calendar.DATE, 1);
>                                 break;
>                         case 4:
>                                         counter = counter + 1;
>                                 c2.add(Calendar.DATE, 1);
>                                 break;
>                         case 5:
>                                         counter = counter + 1;
>                                 c2.add(Calendar.DATE, 1);
>                                 break;
>                         case 6:
>                                         counter = counter + 1;
>                                 c2.add(Calendar.DATE, 1);
>                                 break;
>                         case 7:
>                                 c2.add(Calendar.DATE, 1);
>                                 break;
>
>                         }
>                 }
>
>                 WorkDaysCalc=counter;
>
>         }
>
> On Dec 7, 10:51 am, Streets Of Boston <[email protected]> wrote:
>
>
>
> > You don't know how many milliseconds there are in a day, or even how
> > many hours there are.
>
> > Most days have 24 hours, one may have 23 and an other may have 25
> > hours ( DST ). And this depends whether your timezone has DST or not.
> > The Calendar class should be able to figure all this out.
>
> > However, if you're just interested in 'before' or 'after', then
> > comparing the dates using the milliseconds is OK, since you don't need
> > to know the exact amount.
>
> >Andrew, post a code snippet and describe exactly what problem you see.
>
> > On Dec 7, 6:38 am, "Dexter&#39;s Brain" <[email protected]> wrote:
>
> > > Doing it the millisecond way might be more confortable.
>
> > > Convert both the dates to milliseconds, and then subtract one from the
> > > other, and then calculate the no of days.
>
> > > Thanks
> > > Kumar Bibekhttp://tech-droid.blogspot.co
>
> > > On Dec 7, 4:52 am,andrewandroid<[email protected]> wrote:
>
> > > > I am running code to return date-based calculations.  The method is
> > > > designed to calculate the number of work days given a beginning and
> > > > ending date and I pass in the elements of the dates, create two
> > > > calendar objects from the two dates and compare them.
>
> > > > Can anybody tell me if there is a bug causing inconsistent results
> > > > from
>
> > > > c2.add(Calendar.DATE, 1);
>
> > > > or possibly the Calendar.after method ...?
>
> > > > c2.set(ccyy, mm, dd);
> > > > c4.set(ccyyNew,mmNew, ddNew);
>
> > > > c4.after(c2)
>
> > > > Please help...- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to