Java Program to Display Time in Different Country Format

Last Updated : 27 Aug, 2026

When an application is used by people from different countries, displaying date and time in a familiar regional format improves readability and user experience. Different regions may use different date orders, month names, languages, and time zones.

  • Java provides Locale to represent regional and language preferences.
  • Date-time formatting classes can use Locale to apply regional formatting rules.
  • By combining Locale, date-time formatting, and time-zone support, the same date and time can be displayed appropriately for users in different regions.

Ways to Display Date and Time in Different Country

Method 1: Using Locale and DateFormat

The Locale class represents a specific language and geographical or cultural region. The DateFormat class can format a date according to the rules associated with a particular locale.

Java
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

public class CountryDateFormat {

    public static void main(String[] args)
    {

        Date date = new Date();

        // Create locales for different regions
        Locale usLocale = Locale.US;
        Locale ukLocale = Locale.UK;
        Locale franceLocale = Locale.FRANCE;
        Locale germanyLocale = Locale.GERMANY;
        Locale japanLocale = Locale.JAPAN;

        // Create date formatters for each locale
        DateFormat usFormat = DateFormat.getDateInstance(
            DateFormat.FULL, usLocale);

        DateFormat ukFormat = DateFormat.getDateInstance(
            DateFormat.FULL, ukLocale);

        DateFormat franceFormat
            = DateFormat.getDateInstance(DateFormat.FULL,
                                         franceLocale);

        DateFormat germanyFormat
            = DateFormat.getDateInstance(DateFormat.FULL,
                                         germanyLocale);

        DateFormat japanFormat = DateFormat.getDateInstance(
            DateFormat.FULL, japanLocale);

        // Display the formatted dates
        System.out.println("USA Format: "
                           + usFormat.format(date));

        System.out.println("UK Format: "
                           + ukFormat.format(date));

        System.out.println("France Format: "
                           + franceFormat.format(date));

        System.out.println("Germany Format: "
                           + germanyFormat.format(date));

        System.out.println("Japan Format: "
                           + japanFormat.format(date));
    }
}

Output
USA Format: Thursday, August 27, 2026
UK Format: Thursday, 27 August 2026
France Format: jeudi 27 août 2026
Germany Format: Donnerstag, 27. August 2026
Japan Format: 2026年8月27日木曜日

Explanation: The above Program creates a Date object containing the current date and then creates different Locale objects for different regions. DateFormat.getDateInstance() uses each locale's regional conventions to format the same date differently.

Note: The exact output can vary depending on the Java version and locale data installed in the environment.

Method 2: Using DateTimeFormatter and Locale

Java 8 introduced the modern Date and Time API in the java.time package. DateTimeFormatter can be combined with Locale to format a date according to a particular language and regional convention.

Java
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

public class CountryDateFormat {

    public static void main(String[] args)
    {

        // Get the current date
        LocalDate date = LocalDate.now();

        // Create formatters for different locales
        DateTimeFormatter usFormat
            = DateTimeFormatter.ofPattern(
                "EEEE, dd MMMM yyyy", Locale.US);

        DateTimeFormatter franceFormat
            = DateTimeFormatter.ofPattern(
                "EEEE, dd MMMM yyyy", Locale.FRANCE);

        DateTimeFormatter germanyFormat
            = DateTimeFormatter.ofPattern(
                "EEEE, dd MMMM yyyy", Locale.GERMANY);

        DateTimeFormatter italyFormat
            = DateTimeFormatter.ofPattern(
                "EEEE, dd MMMM yyyy", Locale.ITALIAN);

        // Display the formatted date
        System.out.println("USA Format: "
                           + date.format(usFormat));

        System.out.println("France Format: "
                           + date.format(franceFormat));

        System.out.println("Germany Format: "
                           + date.format(germanyFormat));

        System.out.println("Italy Format: "
                           + date.format(italyFormat));
    }
}

Output
USA Format: Thursday, 27 August 2026
France Format: jeudi, 27 août 2026
Germany Format: Donnerstag, 27 August 2026
Italy Format: giovedì, 27 agosto 2026

Explanation: In above Program, DateTimeFormatter defines the required date pattern, while the Locale determines the language used for names such as the day and month. This approach is recommended for modern Java applications because it uses the Java 8+ Date and Time API.

Method 3: Displaying Date and Time for Different Time Zones

Formatting according to a country or region may also require displaying the local time for that region. In this case, ZonedDateTime and ZoneId can be used.

Java
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class CountryTimeZone {

    public static void main(String[] args)
    {

        // Specify the date and time format
        DateTimeFormatter formatter
            = DateTimeFormatter.ofPattern(
                "dd/MM/yyyy HH:mm:ss z");

        // Get current date and time for different time
        // zones
        ZonedDateTime india
            = ZonedDateTime.now(ZoneId.of("Asia/Kolkata"));

        ZonedDateTime usa = ZonedDateTime.now(
            ZoneId.of("America/New_York"));

        ZonedDateTime uk
            = ZonedDateTime.now(ZoneId.of("Europe/London"));

        ZonedDateTime japan
            = ZonedDateTime.now(ZoneId.of("Asia/Tokyo"));

        // Display the date and time
        System.out.println("India: "
                           + india.format(formatter));

        System.out.println("USA: " + usa.format(formatter));

        System.out.println("UK: " + uk.format(formatter));

        System.out.println("Japan: "
                           + japan.format(formatter));
    }
}

Output
India: 27/08/2026 09:59:00 IST
USA: 27/08/2026 00:29:00 EDT
UK: 27/08/2026 05:29:00 BST
Japan: 27/08/2026 13:29:00 JST

Explanation: In above Program, ZonedDateTime stores the date, time, and time-zone information together. ZoneId.of() specifies the required region, allowing the program to display the corresponding local time.

Method 4: Using Locale with ZonedDateTime

Locale controls the language and formatting conventions, while ZoneId controls the actual time zone. Both can be used together when an application needs localized date and time.

Java
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

public class LocalizedDateTime {

    public static void main(String[] args)
    {

        ZonedDateTime dateTime
            = ZonedDateTime.now(ZoneId.of("Asia/Kolkata"));

        // Create a formatter for French
        DateTimeFormatter frenchFormatter
            = DateTimeFormatter.ofPattern(
                "EEEE, dd MMMM yyyy HH:mm:ss",
                Locale.FRANCE);

        // Create a formatter for German
        DateTimeFormatter germanFormatter
            = DateTimeFormatter.ofPattern(
                "EEEE, dd MMMM yyyy HH:mm:ss",
                Locale.GERMANY);

        System.out.println("French Format: " + dateTime.format(frenchFormatter));

        System.out.println("German Format: " + dateTime.format(germanFormatter));
    }
}

Output
French Format: jeudi, 27 août 2026 10:03:22
German Format: Donnerstag, 27 August 2026 10:03:22

Explanation: In above Program, ZoneId determines the time being displayed, while Locale determines the language used for the day and month names. This is useful for applications that support users from multiple countries.



Comment