82 lines
2.2 KiB
Java
82 lines
2.2 KiB
Java
package com.tarisan.chipcard.tpvvs.webservicetrayicon.accesodatos;
|
|
|
|
import es.chipcard.util.SerClsFecha;
|
|
|
|
public class DataBaseUtil {
|
|
private static String sTimestampFormatDB=null;
|
|
private static java.text.DecimalFormat objPesoFormatter= null;
|
|
|
|
public static String getCurrentDateForDB(){
|
|
SerClsFecha objFecha=new SerClsFecha();
|
|
String sTS=objFecha.toString(getTimestampFormatForDB());
|
|
while(sTS.length()<getTimestampFormatForDB().length()){
|
|
sTS=sTS+"0";
|
|
}
|
|
return sTS;
|
|
}
|
|
|
|
private static String getTimestampFormatForDB(){
|
|
if(sTimestampFormatDB==null){
|
|
sTimestampFormatDB="yyyy-MM-dd HH:mm:ss.SSS";
|
|
}
|
|
return sTimestampFormatDB;
|
|
}
|
|
|
|
public static String FormatSQLStringField(String sValue){
|
|
if(sValue==null)
|
|
return "NULL";
|
|
if(sValue.equalsIgnoreCase("NULL"))
|
|
return "NULL";
|
|
return "'"+sValue+"'";
|
|
}
|
|
|
|
public static String FormatSQLDoubleField(String sValue){
|
|
if(sValue==null)
|
|
return "NULL";
|
|
if(sValue.equalsIgnoreCase("NULL"))
|
|
return "NULL";
|
|
String sRetorno="0";
|
|
try{
|
|
sValue=getPesoDoubleFormat().format(Double.parseDouble(sValue));
|
|
}catch(Exception err){}
|
|
return sValue;
|
|
}
|
|
|
|
public static String FormatSQLDoubleField(double dblValue){
|
|
if(dblValue<0)
|
|
return "NULL";
|
|
String sRetorno="0";
|
|
try{
|
|
sRetorno=getPesoDoubleFormat().format(dblValue);
|
|
}catch(Exception err){}
|
|
return sRetorno;
|
|
}
|
|
|
|
|
|
public static String FormatSQLTimestampField(String sValue){
|
|
if(sValue==null)
|
|
return "NULL";
|
|
if(sValue.length()<19)
|
|
return "NULL";
|
|
return "'"+sValue+"'";
|
|
}
|
|
|
|
public static String FormatSQLIntegerField(int nValue){
|
|
if(nValue==-1)
|
|
return "NULL";
|
|
return String.valueOf(nValue);
|
|
}
|
|
|
|
public static java.text.DecimalFormat getPesoDoubleFormat(){
|
|
if(objPesoFormatter==null){
|
|
//new java.text.DecimalFormat("0000000#.##");
|
|
java.text.DecimalFormatSymbols unusualSymbols = new java.text.DecimalFormatSymbols();
|
|
unusualSymbols.setDecimalSeparator('.');
|
|
//unusualSymbols.setGroupingSeparator('.');
|
|
String sPattern = "#######0.000";
|
|
objPesoFormatter = new java.text.DecimalFormat(sPattern, unusualSymbols);
|
|
}
|
|
return objPesoFormatter;
|
|
}
|
|
}
|