Package org.joda.time.format
Class PeriodFormatterBuilder.Separator
java.lang.Object
org.joda.time.format.PeriodFormatterBuilder.Separator
- All Implemented Interfaces:
PeriodParser,PeriodPrinter
- Enclosing class:
PeriodFormatterBuilder
Handles a separator, that splits the fields into multiple parts.
For example, the 'T' in the ISO8601 standard.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PeriodParserprivate PeriodPrinterprivate final PeriodParserprivate final PeriodPrinterprivate final Stringprivate final String[]private final Stringprivate final booleanprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionSeparator(String text, String finalText, String[] variants, PeriodPrinter beforePrinter, PeriodParser beforeParser, boolean useBefore, boolean useAfter) -
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.(package private) PeriodFormatterBuilder.Separatorfinish(PeriodPrinter afterPrinter, PeriodParser afterParser) intparseInto(ReadWritablePeriod period, String periodStr, 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.
-
Field Details
-
iText
-
iFinalText
-
iParsedForms
-
iUseBefore
private final boolean iUseBefore -
iUseAfter
private final boolean iUseAfter -
iBeforePrinter
-
iAfterPrinter
-
iBeforeParser
-
iAfterParser
-
-
Constructor Details
-
Separator
Separator(String text, String finalText, String[] variants, PeriodPrinter beforePrinter, PeriodParser beforeParser, boolean useBefore, boolean useAfter)
-
-
Method Details
-
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 modifiedperiodStr- 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
-
finish
-