Class DoubleConverter

  • All Implemented Interfaces:
    java.util.function.DoubleFunction<java.lang.String>

    public class DoubleConverter
    extends java.lang.Object
    implements java.util.function.DoubleFunction<java.lang.String>
    A function that converts double values to a string representation with a maximum number of decimal places.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.text.DecimalFormat formatter  
    • Constructor Summary

      Constructors 
      Constructor Description
      DoubleConverter​(int dp)
      Creates a new function that converts double values to strings with the maximum number of decimal places as specified.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String apply​(double value)
      Returns a string representation of the specified value.
      • Methods inherited from class java.lang.Object

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

      • formatter

        private final java.text.DecimalFormat formatter
    • Constructor Detail

      • DoubleConverter

        public DoubleConverter​(int dp)
        Creates a new function that converts double values to strings with the maximum number of decimal places as specified.
        Parameters:
        dp - the max decimal places (in the range 1 to 10).
    • Method Detail

      • apply

        public java.lang.String apply​(double value)
        Returns a string representation of the specified value.
        Specified by:
        apply in interface java.util.function.DoubleFunction<java.lang.String>
        Parameters:
        value - the value.
        Returns:
        A string representation of the specified value.