Image

synchronizing Calendars

As a side interest to my hobby of astronomy, I'm interested in calendaring systems and timekeeping. I'm trying to use the com.ibm.icu.util.*Calendar classes to create a little app that will display the dates in various systems whenever I change any one of them. I thought it would be a fun exercise, and useful to learn a bit more about Java.

The problem is how to keep them in sync. There is no "CalendarChangeEvent" and even if there were the calendars provide no facility for listening for it either. I have started to try to write my own, but all the instruction I've ever had on events is how to listen for and handle ones that the OS creates for you. How do I write my own event? How should I signal my listeners that the event happened? I can't find any tutorials on this sort of thing, and my attempts feel clumsy to me. I think my situation is a little unique in that not only do the objects need to know about all the listeners it has, but the listener also needs to know about all the objects (so it can pass the signal to sync on to them). Or if there's an easier route I should be taking, please let me know.

This appears to be a situation where multiple inheritance would really really be helpful, since all the classes I derive from any *Calendar also will need to implement the exact same code for the events. I'm using an interface, but I'm still implementing the code multiple times. The best I can do is put docs in the interface reminding myself "now when you implement this, it has to do X and Y".