Java Examples - Display time in Italian Language

Advertisements


Problem Description:

How to display time in different languages?

Solution:

This example uses DateFormat class to display time in Italian.

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");
      DateFormat df = DateFormat.getDateInstance
      (DateFormat.FULL, locItalian);
      System.out.println("today is "+ df.format(d1));
   }
}

Result:

The above code sample will produce the following result.

today is Sat Feb 22 23:59:54 CST 2014
today is sabato 22 febbraio 2014


Advertisements
Advertisements