Displaying a number:
System.out.println(
MessageFormat.format("Hello ''{0, number, 0}''", 1500));
Displaying text in quotes:
System.out.println("My name is ''{0}'', "ilyia")
Displaying date:
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(dateFormat.format(new Date()));
Displaying time:
DateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
System.out.println(timeFormat.format(new Date()));
Note1: Precise formats are not i18n friendly. Date and Time should be displayed in user's locale.
Note2: DateFormat is not synchronized. If used by multiple threads it's method calls must be synchronized.
Thursday, December 14, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment