Documentation of 'org.supercsv.cellprocessor.FmtNumber' Java class
FmtNumber
org.supercsv.cellprocessor

Class FmtNumber

  • All Implemented Interfaces:
    CellProcessor, DoubleCellProcessor, LongCellProcessor


    public class FmtNumber
    extends CellProcessorAdaptor
    implements DoubleCellProcessor, LongCellProcessor
    Converts a double into a formatted string using the DecimalFormat class and the default locale. This is useful, when you need to show numbers with a specific number of digits.

    Please be aware that the constructors that use DecimalFormat are not thread-safe, so it is generally better to use the constructors that accept a date format String.

    In the format string, the following characters are defined as :

     0   - means Digit
     #   - means Digit, zero shows as absent (works only as zero padding on the right hand side of the number)
     .   - means Decimal separator or monetary decimal separator
     -   - means Minus sign
     ,   - means Grouping separator
     

    If you want to convert from a String to a decimal, use the ParseDouble or ParseBigDecimal processor.
    Since:
    1.50
    • Constructor Summary

      Constructors 
      Constructor and Description
      FmtNumber(java.text.DecimalFormat formatter)
      Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format.
      FmtNumber(java.text.DecimalFormat formatter, StringCellProcessor next)
      Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format, then calls the next processor in the chain.
      FmtNumber(java.lang.String decimalFormat)
      Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format String.
      FmtNumber(java.lang.String decimalFormat, StringCellProcessor next)
      Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format String, then calls the next processor in the chain.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Object execute(java.lang.Object value, CsvContext context)
      This method is invoked by the framework when the processor needs to process data or check constraints.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FmtNumber

        public FmtNumber(java.lang.String decimalFormat)
        Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format String. This constructor is thread-safe.
        Parameters:
        decimalFormat - the decimal format String (see DecimalFormat)
        Throws:
        java.lang.NullPointerException - if decimalFormat is null
      • FmtNumber

        public FmtNumber(java.lang.String decimalFormat,
                         StringCellProcessor next)
        Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format String, then calls the next processor in the chain. This constructor is thread-safe.
        Parameters:
        decimalFormat - the decimal format String (see DecimalFormat)
        next - the next processor in the chain
        Throws:
        java.lang.NullPointerException - if decimalFormat or next is null
      • FmtNumber

        public FmtNumber(java.text.DecimalFormat formatter)
        Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format. This constructor is not thread-safe.
        Parameters:
        formatter - the DecimalFormat
        Throws:
        java.lang.NullPointerException - if formatter is null
      • FmtNumber

        public FmtNumber(java.text.DecimalFormat formatter,
                         StringCellProcessor next)
        Constructs a new FmtNumber processor, which converts a double into a formatted string using the supplied decimal format, then calls the next processor in the chain. This constructor is not thread-safe.
        Parameters:
        formatter - the DecimalFormat
        next - the next processor in the chain
        Throws:
        java.lang.NullPointerException - if formatter or next is null
    • Method Detail

      • execute

        public java.lang.Object execute(java.lang.Object value,
                                        CsvContext context)
        This method is invoked by the framework when the processor needs to process data or check constraints.
        Specified by:
        execute in interface CellProcessor
        Throws:
        SuperCsvCellProcessorException - if value is null or not a Number, or if an invalid decimalFormat String was supplied

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.