"Date selection is a problem that pops up every few months when you build client-side graphical user interfaces (GUIs). Unfortunately, Java doesn't provide anything like a DateChooser class, and the date-selection widgets I found in a recent Web search were too heavyweight for my purposes. I wanted something clean, unobtrusive, and flexible. Figure 1 shows a few variants of this article's class, so you can see what I mean by "clean" at the display level."
"The getDateInstance method shown in the code above, with no arguments, creates an object in the default format or style. Java also provides some alternative styles for dates, which you can obtain through the overloaded getDateInstance(int style). For convenience' sake, DateFormat provides some ready-made constants that you can use as arguments in the getDateInstance method. Some examples are SHORT, MEDIUM, LONG, and FULL, which are demonstrated in the program below:"
"Scientists believe you need a wormhole (or some other exotic device) to travel through time. But in 2002, I discovered another way to visit the past and any one of the many possible futures. All this computer-based technique requires is an appropriate programming language, such as Java. I prefer to use Java because Java's support for big integers and buffered images greatly facilitates the implementation of this technique."
"You will discover that results vary based on your platform. Java developers on Linux enjoy 1-millisecond (ms) resolution, while Windows 98 users suffer with 50-ms resolution. In most cases, the actual resolution has nothing to do with the fact that System.currenTimeMillis()'s return value is current time in milliseconds."
"Since DST policy is set by national and regional governments, changes in DST policy occur at different times in different countries. Some countries are currently extending their DST periods, thereby changing the dates on which DST will come into effect in a given year. Some countries do not implement any DST at all. So, regardless of where in the world you live, you should anticipate that changes in DST and timezone rules might occur at some point, and be ready to adjust clocks accordingly on the approved dates when these decisions are made. For Java technology-based applications that need to know the exact time in a given location, it is recommended to keep the Java Runtime Environment (JRE) software updated with these latest DST rules. See Timezone Data Versions in the JRE Software to see which Olson data version is included in your version of the JRE software."
"The life of a Java programmer: after you write and deploy your app, you get an e-mail, written in French. After translation, it turns out to be mail flaming you for not putting your date in European format. Ouch!"
"And there you have it. Pick two dates, feed a Calendar object representation of them into this method, and it will tell you how many days they are apart. This method could be modified to work on months instead of days, and there is even a convenient HOUR_OF_DAY field value to do similar comparisons on an hourly basis (which, if you or your code works in one of the US regions with DST, might be worth using at least two days out of the year)."
"Business applications often require date and time calculations. Furthermore, in a global environment, these calculations must be localized for various geographical regions in which the application is running. The Java platform took a huge step in streamlining the way it deals with date and time by introducing the abstract java.util.Calendar class. Subclasses of Calendar interpret a date according to the rules of a specific calendar system. One such subclass is java.util.GregorianCalendar. You can use the methods and properties of GregorianCalendar for many of your date and time calculations and comparisons."