Class PeriodFormat.DynamicWordBased

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private PeriodFormatter iFormatter
      The formatter with the locale selected at construction time.
    • 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.
      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.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • iFormatter

        private final PeriodFormatter iFormatter
        The formatter with the locale selected at construction time.
    • Constructor Detail

    • 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 interface PeriodPrinter
        Parameters:
        period - the period to use
        stopAt - stop counting at this value, enter a number ≥ 256 to count all
        locale - 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 interface PeriodPrinter
        Parameters:
        period - the period to use
        locale - 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 interface PeriodPrinter
        Parameters:
        buf - the formatted period is appended to this buffer
        period - the period to format
        locale - 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 interface PeriodPrinter
        Parameters:
        out - the formatted period is written out
        period - the period to format
        locale - the locale to use
        Throws:
        java.io.IOException
      • getPrinter

        private PeriodPrinter getPrinter​(java.util.Locale locale)
      • 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 interface PeriodParser
        Parameters:
        period - a period that will be modified
        periodStr - text to parse
        position - position to start parsing from
        locale - the locale to use for parsing
        Returns:
        new position, if negative, parse failed. Apply complement operator (~) to get position of failure
      • getParser

        private PeriodParser getParser​(java.util.Locale locale)