aspose file tools*
The moose likes Beginning Java and the fly likes Calendar weirdness... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calendar weirdness..." Watch "Calendar weirdness..." New topic
Author

Calendar weirdness...

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
I'm trying to develop a simple method that prints the day, month, day number, and year from the current day forward for 4 months.

For example, from today forward it would start like this:



I've got it working but something strange happens when it rolls past the current year....the loop becomes infinite and it doesn't stop after 4 months! If it doesn't go beyond the current year...it only shows 4 months worth of lines!

Here's my code:



Why does it not stop after 4 months if it rolls past Dec of the current year? I know I must be missing something obvious but I'm getting fatigued w/ it...hopefully someone can explain?

Thanks!
fred Joly
Ranch Hand

Joined: Jan 19, 2006
Posts: 55
You said "month" is an int.
So imagine you start in month = 10.
I guess Calendar.MONTH is always smaller than 14....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calendar weirdness...