Skip to main content

Posts

Showing posts from October, 2011

Formatting a Number Using a Custom Format

A pattern of special characters is used to specify the format of the number. This example demonstrates some of the characters. For a complete listing, see the javadoc documentation for the DecimalFormat class. There is no symbol that either displays a digit or a blank if no digit present. Hence, it is not possible to format a number so that it will have a specific width. To achieve a specific width, you must manually pad the formatted number. Examples: COPY // The 0 symbol shows a digit or 0 if no digit present NumberFormat formatter = new DecimalFormat("000000"); String s = formatter.format( -1234.567 ); // -001235 // notice that the number was rounded up // The # symbol shows a digit or nothing if no digit present formatter = new DecimalFormat("##"); s = formatter.format( -1234.567 ); // -1235 s = formatter.format( 0 ); // 0 formatter = new DecimalFormat("##00"); s = formatter.format( 0 ); // 00 ...

Install PostgreSQL 8.4 Database Server on CentOS, Fedora, Red Hat

This is quick guide howto install PostgreSQL 8.4 (current stable 8.4.7) database server on CentOS, Fedora and Red Hat. Fedora 14, Fedora 13, CentOS 5.5 and Red Hat (RHEL) 5.5 has PostgreSQL 8.4 database server as default so extra repositories is not needed. Personally, I like to use Postgres own repositories, because the latest version of PostgreSQL may be quickly and easily installed. The following commands run as root and postgres user, so “su -” or “sudo -i” first. Install PostgreSQL 8.4 Database Server Using PostgreSQL’s repositories Install PostgreSQL repository: ## CentOS rpm -Uvh http: // yum.pgrpms.org / reporpms / 8.4 / pgdg-centos- 8.4 - 2 .noarch.rpm   ## Fedora rpm -Uvh http: // yum.pgrpms.org / reporpms / 8.4 / pgdg-fedora- 8.4 - 2 .noarch.rpm   ## Red Hat rpm -Uvh http: // yum.pgrpms.org / reporpms / 8.4 / pgdg-redhat- 8.4 - 2 .noarch.rpm Install postgresql and postgresql-server packages from PostgreSQL’s repositories: yum install postgre...