Wednesday, December 20, 2006

Process List

  • Executing "ps -ef" lists all processes even indicating the command line that was used to start the process.
  • Executing "jps" will display PIDs of all running JREs.

Thursday, December 14, 2006

Using MessageFormat

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.