Class TimeConverter

java.lang.Object
com.twelvemonkeys.util.convert.NumberConverter
com.twelvemonkeys.util.convert.TimeConverter
All Implemented Interfaces:
PropertyConverter

public class TimeConverter extends NumberConverter
Converts strings to times and back.

This class has a static cache of TimeFormats, to avoid creation and parsing of timeformats every time one is used.

Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/util/convert/TimeConverter.java#1 $
Author:
Harald Kuhr, last modified by $Author: haku $
  • Constructor Details

    • TimeConverter

      public TimeConverter()
  • Method Details

    • toObject

      public Object toObject(String pString, Class pType, String pFormat) throws ConversionException
      Converts the string to a time, using the given format for parsing.
      Specified by:
      toObject in interface PropertyConverter
      Overrides:
      toObject in class NumberConverter
      Parameters:
      pString - the string to convert.
      pType - the type to convert to. PropertyConverter implementations may choose to ignore this parameter.
      pFormat - the format used for parsing. PropertyConverter implementations may choose to ignore this parameter. Also, implementations that require a parser format, should provide a default format, and allow null as the format argument.
      Returns:
      the object created from the given string. May safely be typecast to com.twelvemonkeys.util.Time
      Throws:
      ConversionException
      See Also:
    • toString

      public String toString(Object pObject, String pFormat) throws ConversionException
      Converts the object to a string, using the given format
      Specified by:
      toString in interface PropertyConverter
      Overrides:
      toString in class NumberConverter
      Parameters:
      pObject - the object to convert.
      pFormat - the format used for parsing. PropertyConverter implementations may choose to ignore this parameter. Also, implementations that require a parser format, should provide a default format, and allow null as the format argument.
      Returns:
      the string representation of the object, on the correct format.
      Throws:
      ConversionException - if the object is not a subclass of com.twelvemonkeys.util.Time
      See Also: