Allowing the selection of date and time format

Date format is the way to present the day, month, and year of a particular calendar system. Even when only the Gregorian calendar is considered, there is no single worldwide standard for the presentation of this information.

The following are some commonly used date formats. Note the variations in the delimiters and in the day (DD or DDD), month (MM), and year (YY or YYYY) sequence.


Some regions suppress leading zeros. As a result 09 appear as 9. Some regions use the last two digits of the year only, where 1991 becomes 91. This may well cause confusion about dates in the 21st century: How do you read 03/02/01?

There are also conventions for long form dates, where the names of the day or month are spelled out fully:

Example: The following are different ways to specify the eighth day of the ninth month of 1994 .

Country Format
Russia 08 sen. 1994 g.
The Netherlands 08 september 1994
Bulgaria 1994-IX-08
Arabic countries 1994/09/08
Germany 8.9.1994
Iran 1373/6/17
Islamic lunar 1415/4/2
Israel 3 Trishrey 5755

Time format, as in date format, also varies around the world. Time format should not be confused with timestamp, which usually appears in internal format instead of presentation format. Timestamps are specified in the ISO/IEC international standard 8601.

Example: The following are different ways to specify two o'clock in the afternoon :

Country Format
Canada 2:00 PM
Canada (Québec) 14 h
Italy 14.00
Sweden kl 14.00
USA 2:00 PM

Guideline C2

Allow the user to select the date and time format.

Example: The following Java program uses the locale-sensitive class DateFormat and the locale that is currently in use to change the behavior of the program.

import java.util.*;

import java.awt.*;

import javax.swing.*;

import java.text.*;

public class DateDisplay extends JApplet {

public void init () {

Date now = new Date();

DateFormat df = DateFormat.getDateTimeInstance


/* use …(DateFormat.FULL,DateFormat.FULL, Locale.US )

to explicitly specify the English Locale or

…(DateFormat.FULL,DateFormat.FULL, Locale.JAPAN )

to explicitly specify the Japanese Locale



JLabel lb = new JLabel(df.format(now));


Font f = new Font("Dialog", Font.BOLD, 24);



public static void main (String[ ] args) {

JFrame f = new JFrame("DateDisplay");

DateDisplay g = new DateDisplay();




’setSize(600, 200);




The result of the DateDisplay program using an English locale will look something like this:

DateDisplay program using an English locale

The result of the DateDisplay program using a Japanese locale will look something like this:

DateDisplay program using a Japanese locale  

Guideline C2-1

Ensure time stamps are correct for the end user.

Guideline C2-2

Ensure dates are clear and correct, taking into account the different formats and different calendars that people use.

For example, in North America the Gregorian calendar is written horizontally left to right and top to bottom; in much of Europe it is written vertically top to bottom and left to right.