// locale italy language in country switzerland
Locale localeItalyInSwitzerland = new Locale("it", "ch");
// default DateFormat using SHORT format
DateFormat format = DateFormat.getInstance();
System.out.println("Default format : " + format.format(new Date()));
// format using date and time format.
DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, localeItalyInSwitzerland);
System.out.println("Date & time format : " + dateTimeFormat.format(new Date()));
// format date only
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, localeItalyInSwitzerland);
System.out.println("Date format : " + dateFormat.format(new Date()));
// format time only
DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, localeItalyInSwitzerland);
System.out.println("Time format : " + timeFormat.format(new Date()));
// general-purpose number format
NumberFormat format1 = NumberFormat.getInstance(localeItalyInSwitzerland);
System.out.println("General purpose format : " + format1.format(1000000));
// general-purpose number format
NumberFormat format2 = NumberFormat.getNumberInstance(localeItalyInSwitzerland);
System.out.println("General purpose format : " + format2.format(1000000));
// currency format
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(localeItalyInSwitzerland);
System.out.println("Currency format : " + currencyFormat.format(1000000));
// integer format
NumberFormat integerFormat = NumberFormat.getIntegerInstance(localeItalyInSwitzerland);
System.out.println("Integer format : " + integerFormat.format(1000000));
// percent format
NumberFormat percentFormat = NumberFormat.getPercentInstance(localeItalyInSwitzerland);
System.out.println("Percent format : " + percentFormat.format(1000000));
Wednesday, October 5, 2011
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment