Ryan Wamsat wrote:Where I'm getting lost at this point is how to perform calculations against this data. How would I go about subtracting the date entered in the dropdown boxes from the current date?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Welcome to Java Dates (in fact, date/times in general). If you want a nicer API for them, you might want to take a look at Joda Time; but it doesn't alter the fact that you need to define what a "date" means for your purposes.
Winston
PS: If you want proper validation of the components, I think you'd be better off having your dropdown lists in year/month/day order.
Ryan Wamsat wrote:And, I don't understand the proper validation comment. What makes that proper over the mmddyyyy format?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote: Make sense?
Ryan Wamsat wrote:But, how do I go about using that information??? An example would really be appreciated.
However, the info that I am trying to figure out is how I construct a mathematical equation for the calendar variables I've already defined.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Ryan Wamsat wrote:Can you assist me with using my variables to perform the math? I've tried:
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Ryan Wamsat wrote:Yes, that makes a lot of sense. But, that kind of dynamic logic is well beyond my current skill level. I hope to get there soon, though.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:Not quite sure what you want. Are you asking: how do I get that information back?
Ryan Wamsat wrote:I'm trying to figure out the number of days between the two dates. For example, if the date entered = January 1, 2012. Then today (8/10/2012) minus 1/1/2012 = 223 days.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Unfortunately, it's a bit fiddly with Java's Date/Calendar API, but the basic idea is this:
1. A day contains 86400 (24*60*60) seconds, or 86400000 milliseconds.
2. Both Date and Calendar can be converted to a millisecond time of the same origin.
3. Subtract the greater time from the lesser and you have the difference in milliseconds.
Paul Clapham wrote:It seems to me you're making a lot of work for yourself. Apparently you need the user to choose a date? Then why not just use a date chooser component? It's true that Java doesn't come with one, but you can find them on the web easily enough.
Ryan Wamsat wrote:I'm beginning to see that I've chosen a difficult task for myself.
But, the goal here isn't to make things easy on me. The real goal is to try to figure out how Java works...
I'm an EXTREME beginner at programming... meaning, I've spent maybe 5 hours poking around on Google, and 3 hours trying to put together this code.
So, in doing this, I'm trying to see how Java would use a Calendar function (or possibly any function that assigns separate variables [month, day, year, in this case] in a similar way) to perform calculations.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Well I'd say that even getting this far in 5 hours is DAMN impressive.
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|