12.2.1 Bypassing Bugs and Platform Evolution
We saw an application of this approach in the Watch example in Chapter 9. At the
start of the implementation, we were using JDK 1.0 for maximum compatibility.
We quickly discovered a number of bugs and signi?¬?cant missing functionality in the
Java Date class. Looking at JDK 1.1, some of these bugs were corrected, but new ones
had been introduced. Despite the addition of extra Calendar, TimeZone and
DateFormat classes, java.sql.Date and java.sql.Timestamp, there were still large areas
of functionality missing. In particular, we needed the ability to add and subtract times
as both points in time and periods of time??”a fairly standard requirement. A more
domain-speci?¬?c requirement was to increment a single unit of a time with rollover, as
HIDING PLATFORM DETAILS 315
watches do when editing the time. For instance, 59 seconds would be followed by
00 seconds, without incrementing the minutes.
Normally we would have implemented our own calls over the top of the existing
Java Data class. In this case, its poor quality, lack of stability, and focus shifting
away from simple time toward esoteric calendars and time zones led us to create
our own METime class. This class interfaced only with low-level platform primitives
like the system millisecond clock and modular integer arithmetic.
Pages:
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591