Class PeriodConverter

java.lang.Object
com.github.joschi.jadconfig.jodatime.converters.PeriodConverter
All Implemented Interfaces:
Converter<org.joda.time.Period>

public class PeriodConverter extends Object implements Converter<org.joda.time.Period>
Allow periods to be passed in as number + unit or as a ISOPeriodFormat (standard, without millis).

Examples:

  • 23sPeriod.seconds(23)
  • 30mPeriod.minutes(30)
  • 30hPeriod.hours(30)
  • 30dPeriod.days(30)
  • 2wPeriod.weeks(2)
  • 1yPeriod.years(1)
See Also:
  • ISOPeriodFormat
  • Constructor Details

    • PeriodConverter

      public PeriodConverter()
  • Method Details

    • convertFrom

      public org.joda.time.Period convertFrom(String value)
      Description copied from interface: Converter
      Returns a typed instance representing the specified String value.
      Specified by:
      convertFrom in interface Converter<org.joda.time.Period>
      Parameters:
      value - The configuration parameter's String value
      Returns:
      A typed instance representing the configuration parameter's value
    • convertTo

      public String convertTo(org.joda.time.Period value)
      Description copied from interface: Converter
      Returns a String instance representing the configuration parameter's value.
      Specified by:
      convertTo in interface Converter<org.joda.time.Period>
      Parameters:
      value - The configuration parameter's typed value
      Returns:
      A String instance representing the configuration parameter's typed value