Java Double to doubleToSingleQuote(String source)

Here you can find the source of doubleToSingleQuote(String source)

Description

replace " with '

License

Open Source License

Parameter

Parameter Description
String source

Return

String

Declaration

public static String doubleToSingleQuote(String source) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*  w  w w.  java 2 s.  c o  m*/
     * replace " with '
     * @param String source
     * @return String
     * @exception none
     */
    public static String doubleToSingleQuote(String source) {
        if (source == null || source.trim().length() == 0)
            return "";
        if (source.indexOf("\"") != -1) {
            StringBuffer buf = new StringBuffer();
            for (int i = 0; i < source.length(); i++) {
                char c = source.charAt(i);
                if (c != '\"') {
                    buf.append(c);
                } else {
                    buf.append("\'");
                }
            }
            return buf.toString();
        }
        return source;
    }

    public static int indexOf(String str, String searchStr) {
        if (str == null || searchStr == null) {
            return -1;
        }
        return str.indexOf(searchStr);
    }
}

Related

  1. doubleToPercent(double value, int precision)
  2. doubleToRational(double number)
  3. doubleToRegisters(double d)
  4. doubleToScale(double val)
  5. doubleToSexagesimal(double value, int precision, double hopr, double lopr)
  6. doubleToSingleQuotes(String str)
  7. doubleToSlider(final double min, final double max, final double value)
  8. doubleToTime(double time)
  9. doubleToUnary(int max, double num)