Java TM  2 Platform
Standard Edition

Package java.text

See:
           Description

 

Interface Summary
AttributedCharacterIterator An AttributedCharacterIterator allows iteration through both text and related attribute information.
CharacterIterator This interface defines a protocol for bidirectional iteration over text.

 

Class Summary
Annotation An Annotation object is used as a wrapper for a text attribute value if the attribute has annotation characteristics.
AttributedCharacterIterator.Attribute Defines attribute keys that are used to identify text attributes.
AttributedString An AttributedString holds text and related attribute information.
BreakIterator The BreakIterator class implements methods for finding the location of boundaries in text.
ChoiceFormat A ChoiceFormat allows you to attach a format to a range of numbers.
CollationElementIterator The CollationElementIterator class is used as an iterator to walk through each character of an international string.
CollationKey A CollationKey represents a String under the rules of a specific Collator object.
Collator The Collator class performs locale-sensitive String comparison.
DateFormat DateFormat is an abstract class for date/time formatting subclasses which formats and parses dates or time in a language-independent manner.
DateFormatSymbols DateFormatSymbols is a public class for encapsulating localizable date-time formatting data, such as the names of the months, the names of the days of the week, and the time zone data.
DecimalFormat DecimalFormat is a concrete subclass of NumberFormat for formatting decimal numbers.
DecimalFormatSymbols This class represents the set of symbols (such as the decimal separator, the grouping separator, and so on) needed by DecimalFormat to format numbers.
FieldPosition FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted output.
Format Format is an abstract base class for formatting locale-sensitive information such as dates, messages, and numbers.
MessageFormat MessageFormat provides a means to produce concatenated messages in language-neutral way.
NumberFormat NumberFormat is the abstract base class for all number formats.
ParsePosition ParsePosition is a simple class used by Format and its subclasses to keep track of the current position during parsing.
RuleBasedCollator The RuleBasedCollator class is a concrete subclass of Collator that provides a simple, data-driven, table collator.
SimpleDateFormat SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner.
StringCharacterIterator StringCharacterIterator implements the CharacterIterater protocol for a String.

 

Exception Summary
ParseException Signals that an error has been reached unexpectedly while parsing.

Package java.text Description

Provides classes and interfaces for handling text, dates, numbers, currency, messages and collation in a manner independent of natural languages. This means your main application or applet can be written to be language-independent, and it can rely upon separate, dynamically-linked localized resources. This allows the flexibility of adding localizations for new localizations at any time.

These classes are capable of formatting dates, numbers, and messages, parsing; searching and sorting strings; and iterating over characters, words, sentences, and line breaks. This package contains three main groups of classes and interfaces:

  • Classes for formatting and parsing
  • Classes for iteration over text
  • Classes for string collation

Formatting and Parsing

FormattingParsing

Dates and numbers are represented internally in a locale-independent way. For example, dates are kept as milliseconds since January 1, 1970, 00:00:00 UCT. When these objects are printed or displayed, they must be converted to localized strings. The locale-specific parts of a date string, such as the time zone string, are separately imported from a locale-specific resource bundle.

The format() method converts the Date object from -604656780000 milliseconds to the form "Tuesday, November 3, 1997 9:47am CST" for the U. S. English locale. The figure shows how the format() method of subclasses of Format enable instances of Number, Date, String, and other objects to be formatted to locale-specific strings.

Conversely, the parseObject() method (and parse() method in subclasses) perform the reverse operation of parsing localized strings and converting them to Number, Date, and String objects. The figure shows how the parse() method is complementary to format(). Any String formatted by format() is guaranteed to be parseable by parseObject().

Java provides six subclasses of Format for formatting dates, numbers, and messages: DateFormat, SimpleDateFormat, NumberFormat, DecimalFormat, ChoiceFormat, and MessageFormat.

String Collation

collate"CollatorRuleBasedCollator

Collator is an abstract base class. Subclasses implement specific collation strategies. One subclass, RuleBasedCollator, is currently provided and is applicable to a wide set of languages. Other subclasses may be created to handle more specialized needs. CollationElementIterator provides an iterator for stepping through each character of a locale-specific string according to the rules of a specific Collator object. CollationKey enables fast sorting of strings by representing a string as a sort key under the rules of a specific Collator object.

Word Breaks

charCharacteruser characterBreakIterator

Locale-Sensitive Classes

 

Locale-Sensitive Classes
NumberFormat
DecimalFormat
DecimalFormatSymbols
MessageFormat
DateFormat
SimpleDateFormat
DateFormatSymbols
Collator
RuleBasedCollator
CollationElementIterator
CollationKey
BreakIterator
Locale-Independent Classes
Format
ChoiceFormat
FieldPosition
ParsePosition
ParseException
StringCharacterIterator
CharacterIterator

 

Package Specification

Related Documentation

  • java.lang.Character (for getType)
  • java.util.Locale
  • java.util.Calendar
  • java.util.GregorianCalendar
  • java.util.Date
  • java.util.ResourceBundle
  • java.util.ListResourceBundle
  • java.util.PropertyResourceBundle
  • java.util.TimeZone
  • java.util.SimpleTimeZone

 

Since:
JDK1.1

Java TM  2 Platform
Standard Edition

Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
VTS OnDemand RHS Banner



Duke's Choice RHS Banner

JavaOne 2014 Replay banner