Package org.joda.time.format
Class PeriodFormatterBuilder.FieldFormatter
java.lang.Object
org.joda.time.format.PeriodFormatterBuilder.FieldFormatter
- All Implemented Interfaces:
PeriodParser,PeriodPrinter
- Enclosing class:
PeriodFormatterBuilder
static class PeriodFormatterBuilder.FieldFormatter
extends Object
implements PeriodPrinter, PeriodParser
Formats the numeric value of a field, potentially with prefix/suffix.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PeriodFormatterBuilder.FieldFormatter[]The array of the latest formatter added for each type.private final intThe index of the field type, 0=year, etc.private final intprivate final intprivate final PeriodFormatterBuilder.PeriodFieldAffixprivate final intprivate final booleanprivate final PeriodFormatterBuilder.PeriodFieldAffix -
Constructor Summary
ConstructorsConstructorDescriptionFieldFormatter(int minPrintedDigits, int printZeroSetting, int maxParsedDigits, boolean rejectSignedValues, int fieldType, PeriodFormatterBuilder.FieldFormatter[] fieldFormatters, PeriodFormatterBuilder.PeriodFieldAffix prefix, PeriodFormatterBuilder.PeriodFieldAffix suffix) FieldFormatter(PeriodFormatterBuilder.FieldFormatter field, PeriodFormatterBuilder.PeriodFieldAffix suffix) -
Method Summary
Modifier and TypeMethodDescriptionintcalculatePrintedLength(ReadablePeriod period, Locale locale) Returns the exact number of characters produced for the given period.intcountFieldsToPrint(ReadablePeriod period, int stopAt, Locale locale) Returns the amount of fields from the given period that this printer will print.voidfinish(PeriodFormatterBuilder.FieldFormatter[] fieldFormatters) (package private) int(package private) longgetFieldValue(ReadablePeriod period) (package private) booleanisSupported(PeriodType type, int field) (package private) booleanisZero(ReadablePeriod period) private intintparseInto(ReadWritablePeriod period, String text, int position, Locale locale) Parses a period from the given text, at the given position, saving the result into the fields of the given ReadWritablePeriod.voidprintTo(Writer out, ReadablePeriod period, Locale locale) Prints a ReadablePeriod to a Writer.voidprintTo(StringBuffer buf, ReadablePeriod period, Locale locale) Prints a ReadablePeriod to a StringBuffer.(package private) voidsetFieldValue(ReadWritablePeriod period, int field, int value)
-
Field Details
-
iMinPrintedDigits
private final int iMinPrintedDigits -
iPrintZeroSetting
private final int iPrintZeroSetting -
iMaxParsedDigits
private final int iMaxParsedDigits -
iRejectSignedValues
private final boolean iRejectSignedValues -
iFieldType
private final int iFieldTypeThe index of the field type, 0=year, etc. -
iFieldFormatters
The array of the latest formatter added for each type. This is shared between all the field formatters in a formatter. -
iPrefix
-
iSuffix
-
-
Constructor Details
-
FieldFormatter
FieldFormatter(int minPrintedDigits, int printZeroSetting, int maxParsedDigits, boolean rejectSignedValues, int fieldType, PeriodFormatterBuilder.FieldFormatter[] fieldFormatters, PeriodFormatterBuilder.PeriodFieldAffix prefix, PeriodFormatterBuilder.PeriodFieldAffix suffix) -
FieldFormatter
FieldFormatter(PeriodFormatterBuilder.FieldFormatter field, PeriodFormatterBuilder.PeriodFieldAffix suffix)
-
-
Method Details
-
finish
-
countFieldsToPrint
Description copied from interface:PeriodPrinterReturns the amount of fields from the given period that this printer will print.- Specified by:
countFieldsToPrintin interfacePeriodPrinter- Parameters:
period- the period to usestopAt- stop counting at this value, enter a number ≥ 256 to count alllocale- the locale to use- Returns:
- amount of fields printed
-
calculatePrintedLength
Description copied from interface:PeriodPrinterReturns the exact number of characters produced for the given period.- Specified by:
calculatePrintedLengthin interfacePeriodPrinter- Parameters:
period- the period to uselocale- the locale to use- Returns:
- the estimated length
-
printTo
Description copied from interface:PeriodPrinterPrints a ReadablePeriod to a StringBuffer.- Specified by:
printToin interfacePeriodPrinter- Parameters:
buf- the formatted period is appended to this bufferperiod- the period to formatlocale- the locale to use
-
printTo
Description copied from interface:PeriodPrinterPrints a ReadablePeriod to a Writer.- Specified by:
printToin interfacePeriodPrinter- Parameters:
out- the formatted period is written outperiod- the period to formatlocale- the locale to use- Throws:
IOException- if an IO error occurs
-
parseInto
Description copied from interface:PeriodParserParses a period from the given text, at the given position, saving the result into the fields of the given ReadWritablePeriod. If the parse succeeds, the return value is the new text position. Note that the parse may succeed without fully reading the text.If it fails, the return value is negative, but the period may still be modified. To determine the position where the parse failed, apply the one's complement operator (~) on the return value.
- Specified by:
parseIntoin interfacePeriodParser- Parameters:
period- a period that will be modifiedtext- text to parseposition- position to start parsing fromlocale- the locale to use for parsing- Returns:
- new position, if negative, parse failed. Apply complement operator (~) to get position of failure
-
parseInt
- Parameters:
text- text to parseposition- position in textlength- exact count of characters to parse- Returns:
- parsed int value
-
getFieldValue
- Returns:
- Long.MAX_VALUE if nothing to print, otherwise value
-
isZero
-
isSupported
-
setFieldValue
-
getFieldType
int getFieldType()
-