static class PeriodFormat.DynamicWordBased extends java.lang.Object implements PeriodPrinter, PeriodParser
| Modifier and Type | Field and Description |
|---|---|
private PeriodFormatter |
iFormatter
The formatter with the locale selected at construction time.
|
| Constructor and Description |
|---|
DynamicWordBased(PeriodFormatter formatter) |
| Modifier and Type | Method and 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.
|
private PeriodParser |
getParser(java.util.Locale locale) |
private PeriodPrinter |
getPrinter(java.util.Locale locale) |
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.lang.StringBuffer buf,
ReadablePeriod period,
java.util.Locale locale)
Prints a ReadablePeriod to a StringBuffer.
|
void |
printTo(java.io.Writer out,
ReadablePeriod period,
java.util.Locale locale)
Prints a ReadablePeriod to a Writer.
|
private final PeriodFormatter iFormatter
DynamicWordBased(PeriodFormatter formatter)
public int countFieldsToPrint(ReadablePeriod period, int stopAt, java.util.Locale locale)
PeriodPrintercountFieldsToPrint in interface PeriodPrinterperiod - the period to usestopAt - stop counting at this value, enter a number ≥ 256 to count alllocale - the locale to usepublic int calculatePrintedLength(ReadablePeriod period, java.util.Locale locale)
PeriodPrintercalculatePrintedLength in interface PeriodPrinterperiod - the period to uselocale - the locale to usepublic void printTo(java.lang.StringBuffer buf,
ReadablePeriod period,
java.util.Locale locale)
PeriodPrinterprintTo in interface PeriodPrinterbuf - the formatted period is appended to this bufferperiod - the period to formatlocale - the locale to usepublic void printTo(java.io.Writer out,
ReadablePeriod period,
java.util.Locale locale)
throws java.io.IOException
PeriodPrinterprintTo in interface PeriodPrinterout - the formatted period is written outperiod - the period to formatlocale - the locale to usejava.io.IOExceptionprivate PeriodPrinter getPrinter(java.util.Locale locale)
public int parseInto(ReadWritablePeriod period, java.lang.String periodStr, int position, java.util.Locale locale)
PeriodParserIf 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.
parseInto in interface PeriodParserperiod - a period that will be modifiedperiodStr - text to parseposition - position to start parsing fromlocale - the locale to use for parsingprivate PeriodParser getParser(java.util.Locale locale)