Formatting and Parsing a Time for a Locale Using Default Formats : Date Format « I18N « Java






Formatting and Parsing a Time for a Locale Using Default Formats

 

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

public class Main {
  public static void main(String[] argv) throws Exception {

    Locale locale = Locale.ITALIAN;
    Date date = new Date();

    String s = DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(date);
    System.out.println(s);
  }
}

   
  








Related examples in the same category

1.Show DateShow Date
2.Simple Date formatSimple Date format
3.Java I18N: Format : Date FormatJava I18N: Format : Date Format
4.Java I18N: Format : Date Format Symbols DemoJava I18N: Format : Date Format Symbols Demo
5.Demonstrate number and date internationalizationDemonstrate number and date internationalization
6.Use some locales choicesUse some locales choices
7.Format some values using the default locale
8.Formatting and Parsing a Time for a Locale: specify the locale when creating the SimpleDateFormat object.
9.Formatting and Parsing a Date for a Locale: specify the locale when creating the SimpleDateFormat object.