org.joda.time.format |
org.joda.time.format package
Provides printing and parsing support for instants and durations. This package
contains simple and advanced classes for formatting.
Formatters are defined by interfaces, and instances are obtained from factory classes.
Most datetime formatters can be obtained from
DateTimeFormat and ISODateTimeFormat .
More advanced formatters can be built by using DateTimeFormatterBuilder .
Similarly there are also classes for parsing and printing periods.
Most period formatters can be obtained from the factory classes
PeriodFormat and ISOPeriodFormat .
More advanced formatters can be built by using PeriodFormatterBuilder .
|
Java Source File Name | Type | Comment |
DateTimeFormat.java | Class | Factory that creates instances of DateTimeFormatter from patterns and styles.
Datetime formatting is performed by the
DateTimeFormatter class.
Three classes provide factory methods to create formatters, and this is one.
The others are
ISODateTimeFormat and
DateTimeFormatterBuilder .
This class provides two types of factory:
For example, to use a patterm:
DateTime dt = new DateTime();
DateTimeFormatter fmt = DateTimeFormat.forPattern("MMMM, yyyy");
String str = fmt.print(dt);
The pattern syntax is mostly compatible with java.text.SimpleDateFormat -
time zone names cannot be parsed and a few more symbols are supported.
All ASCII letters are reserved as pattern letters, which are defined as follows:
Symbol Meaning Presentation Examples
------ ------- ------------ -------
G era text AD
C century of era (>=0) number 20
Y year of era (>=0) year 1996
x weekyear year 1996
w week of weekyear number 27
e day of week number 2
E day of week text Tuesday; Tue
y year year 1996
D day of year number 189
M month of year month July; Jul; 07
d day of month number 10
a halfday of day text PM
K hour of halfday (0~11) number 0
h clockhour of halfday (1~12) number 12
H hour of day (0~23) number 0
k clockhour of day (1~24) number 24
m minute of hour number 30
s second of minute number 55
S fraction of second number 978
z time zone text Pacific Standard Time; PST
Z time zone offset/id zone -0800; -08:00; America/Los_Angeles
' escape for text delimiter
'' single quote literal '
The count of pattern letters determine the format.
Text: If the number of pattern letters is 4 or more,
the full form is used; otherwise a short or abbreviated form is used if
available.
Number: The minimum number of digits. |
DateTimeFormatter.java | Class | Controls the printing and parsing of a datetime to and from a string.
This class is the main API for printing and parsing used by most applications.
Instances of this class are created via one of three factory classes:
An instance of this class holds a reference internally to one printer and
one parser. |
DateTimeFormatterBuilder.java | Class | Factory that creates complex instances of DateTimeFormatter via method calls.
Datetime formatting is performed by the
DateTimeFormatter class.
Three classes provide factory methods to create formatters, and this is one.
The others are
DateTimeFormat and
ISODateTimeFormat .
DateTimeFormatterBuilder is used for constructing formatters which are then
used to print or parse. |
DateTimeParser.java | Interface | Internal interface for parsing textual representations of datetimes.
Application users will rarely use this class directly. |
DateTimeParserBucket.java | Class | DateTimeParserBucket is an advanced class, intended mainly for parser
implementations. |
DateTimePrinter.java | Interface | Internal interface for creating textual representations of datetimes.
Application users will rarely use this class directly. |
FormatUtils.java | Class | Utility methods used by formatters. |
ISODateTimeFormat.java | Class | Factory that creates instances of DateTimeFormatter for the ISO8601 standard.
Datetime formatting is performed by the
DateTimeFormatter class.
Three classes provide factory methods to create formatters, and this is one.
The others are
DateTimeFormat and
DateTimeFormatterBuilder .
ISO8601 is the international standard for data interchange. |
ISOPeriodFormat.java | Class | Factory that creates instances of PeriodFormatter for the ISO8601 standard. |
PeriodFormat.java | Class | Factory that creates instances of PeriodFormatter. |
PeriodFormatter.java | Class | Controls the printing and parsing of a time period to and from a string.
This class is the main API for printing and parsing used by most applications.
Instances of this class are created via one of three factory classes:
An instance of this class holds a reference internally to one printer and
one parser. |
PeriodFormatterBuilder.java | Class | Factory that creates complex instances of PeriodFormatter via method calls.
Period formatting is performed by the
PeriodFormatter class.
Three classes provide factory methods to create formatters, and this is one.
The others are
PeriodFormat and
ISOPeriodFormat .
PeriodFormatterBuilder is used for constructing formatters which are then
used to print or parse. |
PeriodParser.java | Interface | Internal interface for parsing textual representations of time periods.
Application users will rarely use this class directly. |
PeriodPrinter.java | Interface | Internal interface for printing textual representations of time periods.
Application users will rarely use this class directly. |
TestAll.java | Class | Entry point for all tests in this package. |
TestDateTimeFormat.java | Class | This class is a Junit unit test for DateTime Formating. |
TestDateTimeFormatStyle.java | Class | This class is a Junit unit test for DateTimeFormat styles. |
TestDateTimeFormatter.java | Class | This class is a Junit unit test for DateTime Formating. |
TestDateTimeFormatterBuilder.java | Class | This class is a Junit unit test for DateTimeFormatterBuilder. |
TestISODateTimeFormat.java | Class | This class is a Junit unit test for ISODateTimeFormat. |
TestISODateTimeFormatParsing.java | Class | This class is a Junit unit test for ISODateTimeFormat parsing. |
TestISODateTimeFormat_Fields.java | Class | This class is a Junit unit test for ISODateTimeFormat. |
TestISOPeriodFormat.java | Class | This class is a Junit unit test for ISOPeriodFormat. |
TestISOPeriodFormatParsing.java | Class | This class is a Junit unit test for ISOPeriodFormat. |
TestPeriodFormat.java | Class | This class is a Junit unit test for PeriodFormat. |
TestPeriodFormatParsing.java | Class | This class is a Junit unit test for PeriodFormat. |
TestPeriodFormatter.java | Class | This class is a Junit unit test for Period Formating. |
TestPeriodFormatterBuilder.java | Class | This class is a Junit unit test for PeriodFormatterBuilder. |
TestTextFields.java | Class | Makes sure that text fields are correct for English. |