DateFormat: getTimeInstance(int style,Locale aLocale) : DateFormat « java.text « Java by API






DateFormat: getTimeInstance(int style,Locale aLocale)

 
/*
 * 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));
  }
}

           
         
  








Related examples in the same category

1.DateFormat.FULL
2.DateFormat.LONG
3.DateFormat.MEDIUM
4.DateFormat.SHORT
5.DateFormat: format(Date date)
6.DateFormat: getAvailableLocales()
7.DateFormat: getDateInstance(int style,Locale aLocale)
8.DateFormat: getDateTimeInstance(int dateStyle, int timeStyle)
9.DateFormat: parse(String dateString)
10.DateFormat: setLenient(boolean lenient)