Class Conversions.Converter

  • Enclosing class:
    Conversions

    public abstract static class Conversions.Converter
    extends java.lang.Object
    A converter converts a value to its representation as a specific target type. Not all target types might be supported for a given value in which case implementations throw an exception. The default implementations of the various conversion methods all operate on the string representation of the underlying value (i.e. call Converter.toString().
    • Constructor Summary

      Constructors 
      Constructor Description
      Converter()  
    • Constructor Detail

      • Converter

        public Converter()
    • Method Detail

      • toString

        public abstract java.lang.String toString()
        Convert to string
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of the converted value
      • toBinary

        public Blob toBinary()
        Convert to binary. This default implementation returns an new instance of StringBasedBlob.
        Returns:
        binary representation of the converted value
      • toLong

        public long toLong()
        Convert to long. This default implementation is based on Long.parseLong(String).
        Returns:
        long representation of the converted value
        Throws:
        java.lang.NumberFormatException
      • toDouble

        public double toDouble()
        Convert to double. This default implementation is based on Double.parseDouble(String).
        Returns:
        double representation of the converted value
        Throws:
        java.lang.NumberFormatException
      • toCalendar

        public java.util.Calendar toCalendar()
        Convert to date. This default implementation is based on ISO8601.parse(String).
        Returns:
        date representation of the converted value
        Throws:
        java.lang.IllegalArgumentException - if the string cannot be parsed into a date
      • toDate

        public java.lang.String toDate()
        Convert to date. This default implementation delegates to toCalendar() and returns the ISO8601.format(Calendar) value of the calendar.
        Returns:
        date representation of the converted value
        Throws:
        java.lang.IllegalArgumentException - if the string cannot be parsed into a date
      • toBoolean

        public boolean toBoolean()
        Convert to boolean. This default implementation is based on Boolean.parseBoolean(String).
        Returns:
        boolean representation of the converted value
      • toDecimal

        public java.math.BigDecimal toDecimal()
        Convert to decimal. This default implementation is based on new BigDecimal(String).
        Returns:
        decimal representation of the converted value
        Throws:
        java.lang.NumberFormatException