The major difference between the standard Java classes and the GWT classes is the ability to switch between different locales for formating dates and numbers at runtime. In
GWT, the deferred binding mechanism is used to load only the logic needed for the current locale into the
application.

In order to use the NumberFormat or DateTimeFormat classes, you should update your module XML file with
the following inherits line:

Using NumberFormat

When using the NumberFormat class, you do not instantiate it directly. Instead, you retrieve an instance by calling one of its static get...Format() methods.
For most cases, you probably want to use the default decimal format:

Note that you can also specify your own pattern for formatting numbers. In the example below, we want to show 6 digits of precision on the right hand side of the decimal and
format the left hand side with zeroes up to the hundred thousands place:

Specifying an invalid pattern will cause the NumberFormat.getFormat() method to throw an java.lang.IllegalArgumentException. The pattern
specification is very rich. Refer to the class
documentation for the full set of features.

If you will be using the same number format pattern more than once, it is most efficient to cache the format handle returned from NumberFormat.getFormat(pattern).

Using DateTimeFormat

GWT provides the DateTimeFormat class to
replace the functionality of the DateFormat and TimeFormat classes from the JRE.

For the DateTimeFormat class, there are a large number of default formats defined.

Like the NumberFormat class, you can also use this class to parse a date from a String into a Date representation. You also have the option of using
the default formats for date and time combinations, or you may build your own using a pattern string. See the DateTimeFormat class documentation for specifics on how to create your own patterns.

Be cautious when straying from the default formats and defining your own patterns. Displaying dates and times incorrectly can be extremely aggravating to international users.
Consider the date:

12/04/07

In some countries this is understood to mean the date December 4th, 2007 in others, it would be April 12th, 2007, in yet another locale, it might mean April 7th, 2012. For
displaying in a common format such as this, use the default formats and let the localization mechanism in the DateTimeFormat do the work for you.