package it.integry.integrywmsnative.core.utility;

import java.text.SimpleDateFormat;
import java.util.Date;

public class UtilityDB {

    public static String valueToString(Object value) {
        String valueString;

        if (value == null) {
            valueString = "NULL";
        } else {

            valueString = value.toString();

            if(value instanceof String) {
                if(UtilityString.isNullOrEmpty((String) value)){
                    valueString = "NULL";
                } else {
                    valueString = "'" + valueString.replaceAll("'","''") + "'";
                }
            } else if (value instanceof Date){

                valueString = "'" + UtilityDate.formatDate((Date) value, UtilityDate.COMMONS_DATE_FORMATS.YMD_DASH) + "'";
            } else if (value instanceof Integer) {

            } else {
                valueString = null;
            }
        }
        return valueString;
    }

}
