Class AgeFormatter

java.lang.Object
ca.phon.session.format.AgeFormatter
All Implemented Interfaces:
Formatter<Period>

@FormatterType(java.time.Period.class) public class AgeFormatter extends Object implements Formatter<Period>
Create formatters for ages stored in Period objects.
  • Field Details

  • Constructor Details

    • AgeFormatter

      public AgeFormatter()
  • Method Details

    • ageToString

      public static String ageToString(Period age)
      Format a Period object as an age string.
      Parameters:
      age -
      Returns:
      age as a string
    • stringToAge

      public static Period stringToAge(String text)
      Return an age string as a Period object
      Parameters:
      text -
      Returns:
      age
      Throws:
      IllegalArgumentException - if the string is not formatted correctly
    • format

      public String format(Period obj)
      Description copied from interface: Formatter
      Convert the given object into a formatted String.
      Specified by:
      format in interface Formatter<Period>
      Returns:
      formatted string
    • parse

      public Period parse(String text) throws ParseException
      Description copied from interface: Formatter
      Parse the given string into a new object instance
      Specified by:
      parse in interface Formatter<Period>
      Returns:
      parsed object
      Throws:
      ParseException - if there was a problem parsing the given text