Chapter 6. Dates and Times................................................................................... 152
6.1 Introduction..................................................................................................... 152
6.2 Finding Today's Date .................................................................................... 153
6.3 Printing Date/Time in a Specified Format.................................................. 155
6.4 Representing Dates in Other Epochs ......................................................... 156
6.5 Converting YMDHMS to a Calendar or Epoch Seconds......................... 157
6.6 Parsing Strings into Dates............................................................................ 157
6.7 Converting Epoch Seconds to DMYHMS .................................................. 159
6.8 Adding to or Subtracting from a Date or Calendar................................... 160
6.9 Difference Between Two Dates................................................................... 161
6.10 Comparing Dates......................................................................................... 162
6.11 Day of Week/Month/Year or Week Number............................................ 164
6.12 Calendar Page............................................................................................. 165
6.13 High-Resolution Timers.............................................................................. 167
6.15 Program: Reminder Service ...................................................................... 170
Chapter 7. Structuring Data with Java .................................................................. 172
7.1 Introduction..................................................................................................... 172
7.2 Data Structuring Using Arrays ..................................................................... 173
7.3 Resizing an Array.......................................................................................... 174
7.4 Like an Array, but More Dynamic................................................................ 176
7.5 Data-Independent Access with Iterators.................................................... 177
7.6 Structuring Data in a Linked List ................................................................. 178
7.7 Mapping with Hashtable and HashMap ..................................................... 181
7.8 Storing Strings in Properties and Preferences.......................................... 182
7.9 Sorting a Collection....................................................................................... 184
7.10 Sorting in Java 1.1....................................................................................... 188
7.11 Avoiding the Urge to Sort ........................................................................... 189
7.12 Sets................................................................................................................ 190
7.13 Finding an Object in a Collection.............................................................. 191
7.14 Converting a Collection to an Array.......................................................... 193
7.15 Rolling Your Own Iterator........................................................................... 194
7.16 Stack.............................................................................................................. 195
7.17 Multidimensional Structures....................................................................... 196
7.18 Finally, Collections ...................................................................................... 198
7.19 Program: Timing Comparisons ................................................................. 200
Chapter 8. Object-Oriented Techniques............................................................... 202
8.1 Introduction..................................................................................................... 202
8.2 Printing Objects: Formatting with toString( ) ............................................. 204
8.3 Overriding the Equals Method..................................................................... 205
8.4 Overriding the Hashcode Method ............................................................... 207
8.5 The Clone Method......................................................................................... 209
8.6 The Finalize Method...................................................................................... 211
8.7 Using Inner Classes ...................................................................................... 212
8.8 Providing Callbacks via Interfaces.............................................................. 213
8.9 Polymorphism/Abstract Methods ................................................................ 216
8.10 Passing Values ............................................................................................ 217