Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Write world-class applications

From Chicago to Copenhagen, Colombia to Cameroon -- Java provides the tools for writing truly international applications

  • Print
  • Feedback
Take a quick look at the first date shown below. What date is this? If you guessed "October 5, 1997," you're wrong! Now look at the second date. What date is this? Are you confused yet?
  1. 10/05/97
  2. 16/10/97
Chances are, if you were born and reared in the United States your first guess was wrong, and you are now mildly puzzled by the appearance of the second date.

On the other hand, if you were born and reared in Europe you're probably wondering what all this is about (don't worry, I promise to pull it all together).

You see, the dates shown above are perfectly valid; I've simply shown them as they would appear in many European countries. The way in which the components of a date -- the year, month, and day -- are combined is largely a matter of local custom. In the United States, we format dates using the month/day/year style. In England, however, it's the day that comes first, followed by the month and year. It's a small difference, but please don't underestimate its importance to the end user.

It's surprising how few of our simplest assumptions about appearance are valid anyplace else. Date formats are perhaps the simplest. But what about time formats and monetary representations, the calendar we use to mark the progress of time, and the character set we use? It's interesting to note that ASCII (American Standard Code for Information Interchange), the character set that formed the basis for over twenty years of American computing, managed to leave out many of the characters necessary to display text in languages as common as French.

It's a small world after all

Since its release, Java has been billed as an international application development solution. When building Java's string- and character-handling toolkit, Sun chose to use Unicode (a character-encoding standard capable of representing 65536 characters from scripts around the world) rather than ASCII. Unfortunately, in early versions of the language, critical support for international computing was missing. (Last month's column, "Use the two "R"s of Java 1.1 -- Readers and Writers," provides more detail on this lack of support.)

This weakness was remedied with the release of JDK 1.1 whose class library included numerous changes necessary to improve international support:

  • Several existing classes were changed to provide better support for Unicode
  • Several classes (the new I/O classes) were added to existing packages
  • One new package (the java.text package that contains classes and interfaces for handling text in a locale-independent way) was added.

Data formats

As I mentioned in the introduction, even the simplest of formatting conventions do not stay the same as we move from country to country (or even as we move within a single country -- the French- and English-speaking parts of Canada, for example). Dates, times, and even numeric representations tend to vary -- often significantly.

Let's take a look at just how much they can vary.

Time
The display of the hours, minutes, and seconds in a day (the time, in other words) seems like it should be the most straightforward of tasks. Surprisingly, it is a haven for hidden traps. First, there's the question of the number of hours in a day. Most folks agree that there are 24. But how are they represented? Two half days of twelve hours (like here in the United States) or one day of 24 hours (what we commonly call "military time")? Then there's the choice of the character that separates hours from minutes. Here in the States, we use the colon (:); in Italy it's the period (.). More perplexingly, there's the question of time zone indication and daylight savings time (some locales have it, some don't).

  • Print
  • Feedback

Resources
  • The internationalization specification http://java.sun.com/products/JDK/1.1/intl/html/intlspecTOC.doc.html
  • The Java Tutorial (on writing global programs) http://www.javasoft.com/docs/books/tutorial/intl/index.html
  • The java.text.DateFormat class http://www.javasoft.com/products/jdk/1.1/docs/api/java.text.DateFormat.html
  • The java.text.NumberFormat class http://www.javasoft.com/products/jdk/1.1/docs/api/java.text.NumberFormat.html
  • The USENET newsgroup news:comp.software.international
  • Previous How-To Java articles