|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.joda.time.format.DateTimeFormatterBuilder
DateTimeFormatterBuilder is used for constructing DateTimeFormatters.
DateTimeFormatters can be built by appending specific fields, patterns, or
other formatters.
For example, a formatter that prints month and year, like "January 1970", can be constructed as follows:
DateTimeFormatter monthAndYear = new DateTimeFormatterBuilder()
.appendMonthOfYearText()
.appendLiteral(' ')
.appendYear(4, 4)
.toFormatter();
DateTimeFormat| Constructor Summary | |
DateTimeFormatterBuilder()
Creates a DateTimeFormatterBuilder with ISOChronology, in the
default time zone and locale. |
|
DateTimeFormatterBuilder(Chronology chrono)
Creates a DateTimeFormatterBuilder with any chronology and the default locale. |
|
DateTimeFormatterBuilder(Chronology chrono,
java.util.Locale locale)
Creates a DateTimeFormatterBuilder with any chronology and locale. |
|
DateTimeFormatterBuilder(DateTimeZone zone)
Creates a DateTimeFormatterBuilder with ISOChronology, in the
given time zone, with the default locale. |
|
DateTimeFormatterBuilder(DateTimeZone zone,
java.util.Locale locale)
Creates a DateTimeFormatterBuilder with ISOChronology, in the
given time zone, with any locale. |
|
| Method Summary | |
DateTimeFormatterBuilder |
append(DateTimeFormatter formatter)
Appends another formatter. |
DateTimeFormatterBuilder |
append(DateTimeParser parser)
Appends just a parser. |
DateTimeFormatterBuilder |
append(DateTimePrinter printer)
Appends just a printer. |
DateTimeFormatterBuilder |
append(DateTimePrinter printer,
DateTimeParser parser)
Appends a printer/parser pair. |
DateTimeFormatterBuilder |
append(DateTimePrinter printer,
DateTimeParser[] parsers)
Appends a printer and a set of matching parsers. |
DateTimeFormatterBuilder |
appendCenturyOfEra(int minDigits,
int maxDigits)
Instructs the printer to emit a numeric century of era field. |
DateTimeFormatterBuilder |
appendClockhourOfDay(int minDigits)
Instructs the printer to emit a numeric clockhourOfDay field. |
DateTimeFormatterBuilder |
appendClockhourOfHalfday(int minDigits)
Instructs the printer to emit a numeric clockhourOfHalfday field. |
DateTimeFormatterBuilder |
appendDayOfMonth(int minDigits)
Instructs the printer to emit a numeric dayOfMonth field. |
DateTimeFormatterBuilder |
appendDayOfWeek(int minDigits)
Instructs the printer to emit a numeric dayOfWeek field. |
DateTimeFormatterBuilder |
appendDayOfWeekShortText()
Instructs the printer to emit a short locale-specific dayOfWeek text. |
DateTimeFormatterBuilder |
appendDayOfWeekText()
Instructs the printer to emit a locale-specific dayOfWeek text. |
DateTimeFormatterBuilder |
appendDayOfYear(int minDigits)
Instructs the printer to emit a numeric dayOfYear field. |
DateTimeFormatterBuilder |
appendEraText()
Instructs the printer to emit a locale-specific era text (BC/AD), and the parser to expect it. |
DateTimeFormatterBuilder |
appendFraction(int minDigits,
int maxDigits,
int rangeInMillis)
Instructs the printer to emit a remainder of time as a decimal fraction, sans decimal point. |
DateTimeFormatterBuilder |
appendFractionOfDay(int minDigits,
int maxDigits)
|
DateTimeFormatterBuilder |
appendFractionOfHour(int minDigits,
int maxDigits)
|
DateTimeFormatterBuilder |
appendFractionOfMinute(int minDigits,
int maxDigits)
|
DateTimeFormatterBuilder |
appendFractionOfSecond(int minDigits,
int maxDigits)
|
DateTimeFormatterBuilder |
appendHalfdayOfDayText()
Instructs the printer to emit a locale-specific AM/PM text, and the parser to expect it. |
DateTimeFormatterBuilder |
appendHourOfDay(int minDigits)
Instructs the printer to emit a numeric hourOfDay field. |
DateTimeFormatterBuilder |
appendHourOfHalfday(int minDigits)
Instructs the printer to emit a numeric hourOfHalfday field. |
DateTimeFormatterBuilder |
appendLiteral(char c)
Instructs the printer to emit a specific character, and the parser to expect it. |
DateTimeFormatterBuilder |
appendLiteral(java.lang.String text)
Instructs the printer to emit specific text, and the parser to expect it. |
DateTimeFormatterBuilder |
appendMillisOfDay(int minDigits)
Instructs the printer to emit a numeric millisOfDay field. |
DateTimeFormatterBuilder |
appendMillisOfSecond(int minDigits)
Instructs the printer to emit a numeric millisOfSecond field. |
DateTimeFormatterBuilder |
appendMinuteOfDay(int minDigits)
Instructs the printer to emit a numeric minuteOfDay field. |
DateTimeFormatterBuilder |
appendMinuteOfHour(int minDigits)
Instructs the printer to emit a numeric minuteOfHour field. |
DateTimeFormatterBuilder |
appendMonthOfYear(int minDigits)
Instructs the printer to emit a numeric monthOfYear field. |
DateTimeFormatterBuilder |
appendMonthOfYearShortText()
Instructs the printer to emit a locale-specific monthOfYear text. |
DateTimeFormatterBuilder |
appendMonthOfYearText()
Instructs the printer to emit a short locale-specific monthOfYear text. |
DateTimeFormatterBuilder |
appendNumeric(DateTimeField field,
int minDigits,
int maxDigits)
Instructs the printer to emit a field value as a decimal number, and the parser to expect an unsigned decimal number. |
DateTimeFormatterBuilder |
appendOptional(DateTimeParser parser)
Appends just a parser element which is optional. |
DateTimeFormatterBuilder |
appendPattern(java.lang.String pattern)
The pattern syntax is compatible with java.text.SimpleDateFormat, but a few more symbols are also supported. |
DateTimeFormatterBuilder |
appendSecondOfDay(int minDigits)
Instructs the printer to emit a numeric secondOfDay field. |
DateTimeFormatterBuilder |
appendSecondOfMinute(int minDigits)
Instructs the printer to emit a numeric secondOfMinute field. |
DateTimeFormatterBuilder |
appendShortText(DateTimeField field)
Instructs the printer to emit a field value as short text, and the parser to expect text. |
DateTimeFormatterBuilder |
appendSignedNumeric(DateTimeField field,
int minDigits,
int maxDigits)
Instructs the printer to emit a field value as a decimal number, and the parser to expect a signed decimal number. |
DateTimeFormatterBuilder |
appendText(DateTimeField field)
Instructs the printer to emit a field value as text, and the parser to expect text. |
DateTimeFormatterBuilder |
appendTimeZoneName()
Instructs the printer to emit a locale-specific time zone name. |
DateTimeFormatterBuilder |
appendTimeZoneOffset(java.lang.String zeroOffsetText,
boolean showSeparators,
int minFields,
int maxFields)
Instructs the printer to emit text and numbers to display time zone offset from UTC. |
DateTimeFormatterBuilder |
appendTimeZoneShortName()
Instructs the printer to emit a short locale-specific time zone name. |
DateTimeFormatterBuilder |
appendWeekOfWeekyear(int minDigits)
Instructs the printer to emit a numeric weekOfWeekyear field. |
DateTimeFormatterBuilder |
appendWeekyear(int minDigits,
int maxDigits)
Instructs the printer to emit a numeric weekyear field. |
DateTimeFormatterBuilder |
appendYear(int minDigits,
int maxDigits)
Instructs the printer to emit a numeric year field. |
DateTimeFormatterBuilder |
appendYearOfCentury(int minDigits,
int maxDigits)
Instructs the printer to emit a numeric year of century field. |
DateTimeFormatterBuilder |
appendYearOfEra(int minDigits,
int maxDigits)
Instructs the printer to emit a numeric yearOfEra field. |
boolean |
canBuildFormatter()
Returns true if toFormatter can be called without throwing an UnsupportedOperationException. |
boolean |
canBuildParser()
Returns true if toParser can be called without throwing an UnsupportedOperationException. |
boolean |
canBuildPrinter()
Returns true if toPrinter can be called without throwing an UnsupportedOperationException. |
void |
clear()
Clears out all the appended elements, allowing this builder to be reused. |
Chronology |
getChronology()
Returns the chronology being used by the formatter builder. |
java.util.Locale |
getLocale()
Returns the locale being used the formatter builder. |
DateTimeFormatter |
toFormatter()
Converts to a DateTimeFormatter that prints and parses using all the appended elements. |
DateTimeParser |
toParser()
Converts to a DateTimeParser that parses using all the appended elements. |
DateTimePrinter |
toPrinter()
Converts to a DateTimePrinter that prints using all the appended elements. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DateTimeFormatterBuilder()
ISOChronology, in the
default time zone and locale.
public DateTimeFormatterBuilder(DateTimeZone zone)
ISOChronology, in the
given time zone, with the default locale.
public DateTimeFormatterBuilder(DateTimeZone zone,
java.util.Locale locale)
ISOChronology, in the
given time zone, with any locale.
public DateTimeFormatterBuilder(Chronology chrono)
chrono - Chronology to use
public DateTimeFormatterBuilder(Chronology chrono,
java.util.Locale locale)
chrono - Chronology to uselocale - Locale to use| Method Detail |
public Chronology getChronology()
public java.util.Locale getLocale()
public DateTimePrinter toPrinter()
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if any formatter element doesn't support
printing
public DateTimeParser toParser()
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if any formatter element doesn't support
parsing
public DateTimeFormatter toFormatter()
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if any formatter element doesn't support
both printing and parsingpublic boolean canBuildPrinter()
public boolean canBuildParser()
public boolean canBuildFormatter()
public void clear()
public DateTimeFormatterBuilder append(DateTimeFormatter formatter)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if formatter is null
public DateTimeFormatterBuilder append(DateTimePrinter printer)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if printer is nullpublic DateTimeFormatterBuilder append(DateTimeParser parser)
java.lang.IllegalArgumentException - if parser is null
public DateTimeFormatterBuilder append(DateTimePrinter printer,
DateTimeParser parser)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if printer or parser is null
public DateTimeFormatterBuilder append(DateTimePrinter printer,
DateTimeParser[] parsers)
throws java.lang.IllegalArgumentException
Only the printer is optional. In addtion, it is illegal for any but the last of the parser array elements to be null. If the last element is null, this represents the empty parser. The presence of an empty parser indicates that the entire array of parse formats is optional.
java.lang.IllegalArgumentException - if any parser element but the last is nullpublic DateTimeFormatterBuilder appendOptional(DateTimeParser parser)
java.lang.IllegalArgumentException - if parser is nullpublic DateTimeFormatterBuilder appendLiteral(char c)
public DateTimeFormatterBuilder appendLiteral(java.lang.String text)
public DateTimeFormatterBuilder appendNumeric(DateTimeField field,
int minDigits,
int maxDigits)
field - field should operate in UTC or be time zone agnosticminDigits - minumum number of digits to printmaxDigits - maximum number of digits to parse, or the estimated
maximum number of digits to print
public DateTimeFormatterBuilder appendSignedNumeric(DateTimeField field,
int minDigits,
int maxDigits)
field - field should operate in UTC or be time zone agnosticminDigits - minumum number of digits to printmaxDigits - maximum number of digits to parse, or the estimated
maximum number of digits to printpublic DateTimeFormatterBuilder appendText(DateTimeField field)
field - field should operate in UTC or be time zone agnosticpublic DateTimeFormatterBuilder appendShortText(DateTimeField field)
field - field should operate in UTC or be time zone agnostic
public DateTimeFormatterBuilder appendFraction(int minDigits,
int maxDigits,
int rangeInMillis)
minDigits - minumum number of digits to print.maxDigits - maximum number of digits to print or parse.rangeInMillis - range of values in fraction
public DateTimeFormatterBuilder appendFractionOfSecond(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to print or parse
public DateTimeFormatterBuilder appendFractionOfMinute(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to print or parse
public DateTimeFormatterBuilder appendFractionOfHour(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to print or parse
public DateTimeFormatterBuilder appendFractionOfDay(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to print or parsepublic DateTimeFormatterBuilder appendMillisOfSecond(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendMillisOfDay(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendSecondOfMinute(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendSecondOfDay(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendMinuteOfHour(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendMinuteOfDay(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendHourOfDay(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendClockhourOfDay(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendHourOfHalfday(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendClockhourOfHalfday(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendDayOfWeek(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendDayOfMonth(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendDayOfYear(int minDigits)
minDigits - minumum number of digits to printpublic DateTimeFormatterBuilder appendWeekOfWeekyear(int minDigits)
minDigits - minumum number of digits to print
public DateTimeFormatterBuilder appendWeekyear(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to parse, or the estimated
maximum number of digits to printpublic DateTimeFormatterBuilder appendMonthOfYear(int minDigits)
minDigits - minumum number of digits to print
public DateTimeFormatterBuilder appendYear(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to parse, or the estimated
maximum number of digits to print
public DateTimeFormatterBuilder appendYearOfEra(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to parse, or the estimated
maximum number of digits to print
public DateTimeFormatterBuilder appendYearOfCentury(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to parse, or the estimated
maximum number of digits to print
public DateTimeFormatterBuilder appendCenturyOfEra(int minDigits,
int maxDigits)
minDigits - minumum number of digits to printmaxDigits - maximum number of digits to parse, or the estimated
maximum number of digits to printpublic DateTimeFormatterBuilder appendHalfdayOfDayText()
public DateTimeFormatterBuilder appendDayOfWeekText()
public DateTimeFormatterBuilder appendDayOfWeekShortText()
public DateTimeFormatterBuilder appendMonthOfYearText()
public DateTimeFormatterBuilder appendMonthOfYearShortText()
public DateTimeFormatterBuilder appendEraText()
public DateTimeFormatterBuilder appendTimeZoneName()
public DateTimeFormatterBuilder appendTimeZoneShortName()
public DateTimeFormatterBuilder appendTimeZoneOffset(java.lang.String zeroOffsetText,
boolean showSeparators,
int minFields,
int maxFields)
zeroOffsetText - Text to use if time zone offset is zero. If
null, offset is always shown.showSeparators - If true, prints ':' separator before minute and
second field and prints '.' separator before fraction field.minFields - minimum number of fields to print, stopping when no
more precision is required. 1=hours, 2=minutes, 3=seconds, 4=fractionmaxFields - maximum number of fields to print
public DateTimeFormatterBuilder appendPattern(java.lang.String pattern)
throws java.lang.IllegalArgumentException
To specify the time format use a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:
The count of pattern letters determine the format.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 RFC 822 time zone text -0800; -08:00 ' escape for text delimiter '' single quote literal '
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. Shorter numbers are zero-padded to this amount.
Year: Numeric presentation for year and weekyear fields are handled specially. For example, if the count of 'y' is 2, the year will be displayed as the zero-based year of the century, which is two digits.
Month: 3 or over, use text, otherwise use number.
Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.
java.lang.IllegalArgumentException
|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||