Home » Java Internationalizing Time

Java Internationalizing Time

by Online Tutorials Library

Internationalizing Time (I18N with Time)

The display format of the time differs from one region to another, so we need to internationalize the time.

For internationalizing the time, the DateFormat class provides some useful methods.

The getTimeInstance() method of the DateFormat class returns the instance of the DateFormat class for the specified style and locale.

Syntax of the getTimeInstance() method is given below:


Example of Internationalizing Time

In this example, we are displaying the current time for the specified locale. The format() method of the DateFormat class receives date object and returns the formatted and localized time as a string. Notice that the object of Date class prints date and time both.

Output:16:22:49 in locale en_GB 4:22:49 PM in locale en_US 16:22:49 in locale fr_FR  

You may also like