This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Zodiac Signs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Zodiac Signs" Watch "Zodiac Signs" New topic
Author

Zodiac Signs

Vino Free
Greenhorn

Joined: Mar 30, 2013
Posts: 2
Hi Guys! I have a program here that generates the zodiac sign and chinese zodiac, but there is a problem. When you enter a month - 13 or higher it generates a result.
What should I do to fix this problem?
Here are my codes:


Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36474
    
  16
Try entering a date, eg 13/14/2015 and getting it printed out. You will probably get 14th Jan 2016. What is probably happening is that the Calendar object is accepting 13 as one month beyond December. Read the Calendar documentation about “leniency”; that may help sort out your problem.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7032
    
  16

Vino Free wrote:What shoul I do to fix this problem?

I think Campbell's basically covered it.

However: Are you familiar with enums? Because both of your "zodiac" types would be a great place to use them.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Vino Free
Greenhorn

Joined: Mar 30, 2013
Posts: 2
Thanks a lot Campbell!
Your suggestion is very helpful.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36474
    
  16
You’re welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Zodiac Signs
 
Similar Threads
Exception
Static method and null
Wats the output..... Explanations needed....
Exception
Code review required for converting dateformat