Format Class
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Format Class

Visual Studio 2005

An abstract class used as the base class for the rest of the format classes in the java.text package.

Package: java.text

Assembly: vjslib (in vjslib.dll)

public abstract class java.text.Format
    extends java.lang.Object
    implements, java.lang.Cloneable

The following example demonstrates the format and parseObject methods of the Format class. This example uses the NumberFormat class, which is a specialization of the abstract Format class.

// format_overview.jsl

import java.math.BigDecimal;
import java.text.*;

public class Program
    public static void main(String[] args)
            // Get a default NumberFormat instance.
            NumberFormat numForm = NumberFormat.getInstance();

            // Format some decimals using the pattern supplied above.
            BigDecimal bd1 = new BigDecimal(22.3423D);
            String dest1 = numForm.format(bd1);
            System.out.println("dest1 = " + dest1);

            BigDecimal bd2 = new BigDecimal(64000D);
            String dest2 = numForm.format(bd2);
            System.out.println("dest2 = " + dest2);

            // Parse the decimal string.
            Object o = numForm.parseObject("123456789.14");
            System.out.println("Number = " + o.toString());
        catch (ParseException ex)

dest1 = 22.342
dest2 = 64,000
Number = 1.2345678914E8
© 2015 Microsoft