× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Yep.. I just figured that out.
See what happens when an RPG'er comes to java.  We just can't get over 
that whole 0 based array thing.  Just wasted about an hour, read the docs, 
and still missed the part where it says 0-11.  Dumb dumb me... must be the 
snow we had this morning.  Thanks for the verification on the code.  I 
really appreciated the help.

Ron Power
Programmer     <--------------------- Are we sure about this??? lol....
Information Services
City Of St. John's, NL
P.O. Box 908
St. John's, NL
A1C 5M2
709-576-8132
rpower@xxxxxxxxxx
http://www.stjohns.ca/
___________________________________________________________________________
Success is going from failure to failure without a loss of enthusiasm. - 
Sir Winston Churchill




Bruce Jin <brucej@xxxxxxxxxxxxxxxxxxxx> 
Sent by: java400-l-bounces@xxxxxxxxxxxx
2006/01/26 11:10 AM
Please respond to
Java Programming on and around the iSeries / AS400 
<java400-l@xxxxxxxxxxxx>


To
Java Programming on and around the iSeries / AS400 
<java400-l@xxxxxxxxxxxx>
cc

Subject
Re: Issues with cal.add?






Note that month starts with 0,1,2,....
You may change these 2 lines:

  Calendar cal = new GregorianCalendar(year, month-1, day);
  month = cal.get(Calendar.MONTH)+1;


RPower@xxxxxxxxxx wrote:
> I have the following method in my class:
>
>         private int newDate(int date, int increment, int targetYear) {
>                 int retdate = 0;
>                 if (date > 0) {
>                         int year = date / 10000;
>                         int month = (date - (year * 10000)) / 100;
>                         int day = date - ((year * 10000) + (month * 
100));
>                         year = targetYear;
>                         Calendar cal = new GregorianCalendar(year, 
month, 
> day);
>                         cal.add(Calendar.DATE, increment);
>                         year = cal.get(Calendar.YEAR);
>                         month = cal.get(Calendar.MONTH);
>                         day = cal.get(Calendar.DAY_OF_MONTH);
>                         retdate = (year * 10000) + (month * 100) + day;
>                 }
>                 return retdate;
>         }
>
> It should take the date and decrease by the amount of the increment 
using 
> the targetYear as the year of the date instead.  Here's the problem.  I 
> sent it the following parms:
> date = 20050502; increment = -2, targetYear = 2007.  When it gets to the 

> cal.add(Calendar.DATE, increment) the value of the date is 2007/05/02 
and 
> I want to decrease it by 2.  It returns 2007/04/31  wtf?  There is no 
such 
> date.  Is this an issue with the calendar class?  Thanks,
>
> Ron Power
> Programmer
> Information Services
> City Of St. John's, NL
> P.O. Box 908
> St. John's, NL
> A1C 5M2
> 709-576-8132
> rpower@xxxxxxxxxx
> http://www.stjohns.ca/
> 
___________________________________________________________________________
> Success is going from failure to failure without a loss of enthusiasm. - 

> Sir Winston Churchill
> 


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.