/*
* Output:
Japan: 11:25 AM
United Kingdom: 11:25:31 PDT
Canada: 11:25:31 o'clock AM PDT
* */
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class MainClass {
public static void main(String args[]) {
Date date = new Date();
DateFormat df;
df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.JAPAN);
System.out.println("Japan: " + df.format(date));
df = DateFormat.getTimeInstance(DateFormat.LONG, Locale.UK);
System.out.println("United Kingdom: " + df.format(date));
df = DateFormat.getTimeInstance(DateFormat.FULL, Locale.CANADA);
System.out.println("Canada: " + df.format(date));
}
}
|