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
static class PeriodFormatterBuilder.Separator extends java.lang.Object implements PeriodPrinter, PeriodParser
Handles a separator, that splits the fields into multiple parts. For example, the 'T' in the ISO8601 standard.
-
-
Field Summary
Fields Modifier and Type Field Description private PeriodParser
iAfterParser
private PeriodPrinter
iAfterPrinter
private PeriodParser
iBeforeParser
private PeriodPrinter
iBeforePrinter
private java.lang.String
iFinalText
private java.lang.String[]
iParsedForms
private java.lang.String
iText
private boolean
iUseAfter
private boolean
iUseBefore
-
Constructor Summary
Constructors Constructor Description Separator(java.lang.String text, java.lang.String finalText, java.lang.String[] variants, PeriodPrinter beforePrinter, PeriodParser beforeParser, boolean useBefore, boolean useAfter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
calculatePrintedLength(ReadablePeriod period, java.util.Locale locale)
Returns the exact number of characters produced for the given period.int
countFieldsToPrint(ReadablePeriod period, int stopAt, java.util.Locale locale)
Returns the amount of fields from the given period that this printer will print.(package private) PeriodFormatterBuilder.Separator
finish(PeriodPrinter afterPrinter, PeriodParser afterParser)
int
parseInto(ReadWritablePeriod period, java.lang.String periodStr, int position, java.util.Locale locale)
Parses a period from the given text, at the given position, saving the result into the fields of the given ReadWritablePeriod.void
printTo(java.io.Writer out, ReadablePeriod period, java.util.Locale locale)
Prints a ReadablePeriod to a Writer.void
printTo(java.lang.StringBuffer buf, ReadablePeriod period, java.util.Locale locale)
Prints a ReadablePeriod to a StringBuffer.
-
-
-
Field Detail
-
iText
private final java.lang.String iText
-
iFinalText
private final java.lang.String iFinalText
-
iParsedForms
private final java.lang.String[] iParsedForms
-
iUseBefore
private final boolean iUseBefore
-
iUseAfter
private final boolean iUseAfter
-
iBeforePrinter
private final PeriodPrinter iBeforePrinter
-
iAfterPrinter
private volatile PeriodPrinter iAfterPrinter
-
iBeforeParser
private final PeriodParser iBeforeParser
-
iAfterParser
private volatile PeriodParser iAfterParser
-
-
Constructor Detail
-
Separator
Separator(java.lang.String text, java.lang.String finalText, java.lang.String[] variants, PeriodPrinter beforePrinter, PeriodParser beforeParser, boolean useBefore, boolean useAfter)
-
-
Method Detail
-
countFieldsToPrint
public int countFieldsToPrint(ReadablePeriod period, int stopAt, java.util.Locale locale)
Description copied from interface:PeriodPrinter
Returns the amount of fields from the given period that this printer will print.- Specified by:
countFieldsToPrint
in 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
public int calculatePrintedLength(ReadablePeriod period, java.util.Locale locale)
Description copied from interface:PeriodPrinter
Returns the exact number of characters produced for the given period.- Specified by:
calculatePrintedLength
in interfacePeriodPrinter
- Parameters:
period
- the period to uselocale
- the locale to use- Returns:
- the estimated length
-
printTo
public void printTo(java.lang.StringBuffer buf, ReadablePeriod period, java.util.Locale locale)
Description copied from interface:PeriodPrinter
Prints a ReadablePeriod to a StringBuffer.- Specified by:
printTo
in interfacePeriodPrinter
- Parameters:
buf
- the formatted period is appended to this bufferperiod
- the period to formatlocale
- the locale to use
-
printTo
public void printTo(java.io.Writer out, ReadablePeriod period, java.util.Locale locale) throws java.io.IOException
Description copied from interface:PeriodPrinter
Prints a ReadablePeriod to a Writer.- Specified by:
printTo
in interfacePeriodPrinter
- Parameters:
out
- the formatted period is written outperiod
- the period to formatlocale
- the locale to use- Throws:
java.io.IOException
-
parseInto
public int parseInto(ReadWritablePeriod period, java.lang.String periodStr, int position, java.util.Locale locale)
Description copied from interface:PeriodParser
Parses 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:
parseInto
in 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
PeriodFormatterBuilder.Separator finish(PeriodPrinter afterPrinter, PeriodParser afterParser)
-
-