Results 1 to 7 of 7
Thread: Calendar Fun, Or not so much.
- 10-06-2011, 06:00 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
Calendar Fun, Or not so much.
I'm attempting to write a simple program that will take in Day Number, Month Number and Year Number from an input box. (In that specific order)
What I'm trying to do is to force the program to check if a given Day Number exists within that specific month. For example, there is no 31st in February, and certain months only have 30 days as opposed to 31 days.
What would be the simplest way to incorporate that kind of check after receiving input for the Day Number and then Month Number, and if it is incorrect, restart the program.
- 10-06-2011, 06:05 PM #2
Re: Calendar Fun, Or not so much.
I'd probably use the Calendar class.
But assuming this is for homework and that's not valid, think about it this way: how would you do this by hand or in your head?How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 10-06-2011, 06:14 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
Re: Calendar Fun, Or not so much.
Well for months 1, 3, 5, 7, 8, 10 and 12 I would note that the maximum value is 31, and for all other months besides 2, I would assign that value to 30.
My problem is since I'm still too inexperienced with using Java, I was thinking that I could use some kind of a switch statement that says these sets of months can only have this many days. The Issue is since the input order has to be Day Number, followed by Month Number, how do I apply that check
- 10-06-2011, 06:25 PM #4
Re: Calendar Fun, Or not so much.
Just store each value in a variable, and do whatever you want with it.
One way is to use a switch statement and if statements. Why don't you give it a go, post an SSCCE demonstrating what you try, and we'll go from there if you get stuck?How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 10-06-2011, 06:47 PM #5
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
Re: Calendar Fun, Or not so much.
What exactly am I storing, I've already created variables for dayNumber, and monthNumber from reading the input dialog box's.
I'm just trying to understand how to properly apply those two variables from the inputs, and make the proper comparison between the two.
- 10-07-2011, 05:09 PM #6
Re: Calendar Fun, Or not so much.
Then I'm not sure what your question is. You've described what you have to do. Where are you stuck? What do you have so far?
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 10-07-2011, 07:01 PM #7
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
question about method calendar.get(Calendar.DAY_OF_WEEK))
By elenora in forum Advanced JavaReplies: 4Last Post: 09-21-2011, 05:39 PM -
Calendar Help Please
By loopsnhoops in forum New To JavaReplies: 4Last Post: 05-24-2011, 11:35 AM -
How to add a calendar????
By zifis in forum New To JavaReplies: 5Last Post: 04-07-2009, 05:04 PM -
calendar
By John in forum SWT / JFaceReplies: 12Last Post: 08-07-2008, 11:54 PM -
Web calendar
By Daniel in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 06-27-2007, 06:36 PM
Bookmarks