Web | This Site

Java Basics Examples
Java Tutorial
Java Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Java Examples - Displaying time in different Country's format

## Problem Description:

How to display time in different country's format?

## Solution:

Following example uses Locale class & DateFormat class to disply date in different Country's format.

    import java.text.DateFormat;
    import java.util.*;

    public class Main {
       public static void main(String[] args) throws Exception {
          Date d1 = new Date();
          System.out.println("today is "+ d1.toString());
          Locale locItalian = new Locale("it","ch");
          DateFormat df = DateFormat.getDateInstance
          (DateFormat.FULL, locItalian);
          System.out.println("today is in Italian Language
          in Switzerland Format : "+ df.format(d1));
       }
    }

## Result:

The above code sample will produce the following result.

    today is Mon Jun 22 02:37:06 IST 2009
    today is in Italian Language in Switzerlandlunedì,
    22. giugno 2009

Advertisement

Online Image Processing

Indian Baby Names