code: public static String fancyStringF(double value, DecimalFormat format, int length, int significant) {
  
          String formatted = fancyString(value, format, length, significant);
  
          int n = length-formatted.length();
          if( n > 0 ) {
              StringBuilder builder = new StringBuilder(n);
              for (int i = 0; i < n; i++) {
                  builder.append(' ');
              }
              return formatted + builder.toString();
          } else {
              return formatted;
          }
      }
docs: Fixed length fancy formatting for doubles. If possible decimal notation is used. If all the significant digits
  can't be shown then it will switch to exponential notation.  If not all the space is needed then it will
  be filled in to ensure it has the specified length.
  
  @param value value being formatted
  @param format default format before exponential
  @param length Maximum number of characters it can take.
  @param significant Number of significant decimal digits to show at a minimum.
  @return formatted string