Class UtilFns


  • public class UtilFns
    extends Object
    Author:
    ashish
    • Field Detail

      • ZERO_DOUBLE

        public static final Double ZERO_DOUBLE
        The zero double.
      • TZ_GMT

        public static final TimeZone TZ_GMT
      • CAL_GMT

        public static final Calendar CAL_GMT
    • Constructor Detail

      • UtilFns

        public UtilFns()
    • Method Detail

      • dateToDays

        public static Long dateToDays​(Date date)
        Returns number of days since 1900-1-0; i.e. 1900-1-0 returns 0 and 1900-1-1 returns 1.
        Parameters:
        date - the date to be calculated.
        Returns:
        number of days since 1900-1-0; i.e. 1900-1-0 returns 0 and 1900-1-1 returns 1.
      • basisToDouble

        public static double basisToDouble​(int basis,
                                           Date settle,
                                           Date maturi,
                                           int dsm)
      • replaceiToi1

        public static String replaceiToi1​(String complex,
                                          String suffix)
        Replace the String i to i1.
        Parameters:
        complex - String of complex.
        Returns:
        String of a complex.
      • cToComplex

        public static ComplexEx cToComplex​(org.apache.commons.math3.complex.Complex c,
                                           String suffix)
        Convert the complex to complex.
        Parameters:
        c - the complex.
        suffix - the suffix.
        Returns:
        the complex.
      • format

        public static String format​(ComplexEx c)
        format Complex number to match Excel format
        Parameters:
        c - the complex number
        Returns:
        the formated Complex number that match Excel format
      • toDouble15

        public static double toDouble15​(double dbl,
                                        int roundingMode)
      • stringToDouble

        public static Double stringToDouble​(String str,
                                            boolean nullable)
                                     throws EvaluationException
        Convert a string to double
        Parameters:
        str - - input value
        nullable - - flag to indicate the return could be null or not
        Returns:
        double value
        Throws:
        EvaluationException
      • toDoubleArray

        public static double[] toDoubleArray​(Object[] objs)
                                      throws EvaluationException
        Convert an object array to a double array
        Parameters:
        objs - an object array
        Returns:
        double array
        Throws:
        EvaluationException
      • getStats

        public static org.apache.commons.math3.stat.descriptive.DescriptiveStatistics getStats​(double[] d)
        Return a commons math DescriptiveStatistics class which is contructed from double array d
        Parameters:
        d - samples
        Returns:
        a DescriptiveStatistics class which is contructed from double array d
      • getRegre

        public static org.apache.commons.math3.stat.regression.SimpleRegression getRegre​(double[] xs,
                                                                                         double[] ys)
                                                                                  throws EvaluationException
        Return a commons math Regression class
        Parameters:
        xs - x-coordinates
        ys - y-coordinates
        Returns:
        a commons math Regression class
        Throws:
        EvaluationException
      • daysToDate

        public static Date daysToDate​(int arg)
        Returns a Date of a given number of days since 1900-1-1 (inclusive); i.e. returns Date at 1900-1-1 given 1
        Parameters:
        arg - number of days since 1900-1-1.
        Returns:
        Date per the given number of days since 1900-1-1.