Unfortunately I also need hours, minutes and seconds but I gave an example with just 3 spinners (instead of six).
My main query is how to ensure each one uses (and updates itself) with the same datemodel?
Joined: Jun 09, 2003
> My main query is how to ensure each one uses (and updates itself) with the same datemodel?
the problem is going to be when the spinner increment/decrement buttons are clicked.
there is no calendar field associated with the model, so the display could end up anything,
if the model doesn't know the field.
it's easy enough to set up with individual models, but the problem is you probably want
the following model adjusted if a maximum is reached/incremented
e.g. display is 31 May, click increment button for 31, it will go to 1
when this happens you probably want May to also 'click-over' to Jun
if so, you may have to build your own action for this, which would involve
setting your own UI for each spinner, to access the creatNext/PreviousButton()'s
remove the actionListeners from those buttons
add your own actionListener, where you
1) create a calendar object from the current display of your 6 spinners (ensuring setLenient is true - default value)
2) add/decrement '1' to the calendar field associated with the button clicked
3) setting each spinner's value to the new calendar date via calendar.get(whateverField)
you now have to work out how you want to handle end of month
e.g. display is 31 May, and you increment the month
1 is added to month --> 31 June --> which becomes 1 July (with lenient true)
or, 30 Apr + 1 month = 30 May (or do you want 31 May)
and then there's February, 31 Jan+1 month = 31 Feb = 3 Mar (or 2 Mar for leap year)
Joined: Jun 09, 2003
in case the above makes little sense, run this
(just found out 31 Jan+1 month = 28 Feb, thought it used to go to 3 Mar)
Joined: Jan 16, 2009
Thanks very much for this Michael
I will have a play with it.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com