⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbutil.java

📁 用Java开发的、实现类似Visio功能的应用程序源码
💻 JAVA
字号:
/**
 *    $Id:DbUtil.java $
 *
 *    Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All rights reserved.
 *
 */
package com.jfimagine.utils.commonutil;

import java.util.Date;
import java.sql.ResultSet;


import com.jfimagine.utils.commonutil.CommonUtil;


/**
 * Database utilities for data processing
 *
 * @author     CookieMaker    
 *
 * @version $Revision: 1.00 $
 */ 
public class DbUtil{

   /**
    *   Convert a java.util.Date to a java.sql.Date
    * 
    *   @param d  A java.util.Date value to be converted
    * 
    *   @return  a java.sql.Date value, null if input is also null
    *
    */
   public static java.sql.Date d2sqld(Date d){
   	if (d==null)
   		return null;
   	else
   		return new java.sql.Date(d.getTime());
   }

   /**
    *   Convert a java.sql.Date to a java.util.Date
    * 
    *   @param d  A java.sql.Date value to be converted
    * 
    *   @return  a java.util.Date value, null if input is also null
    *
    */
   public static Date sqld2d(java.sql.Date d){
   	if (d==null)
   		return null;
   	else
   		return new Date(d.getTime()); 
   }

	
   /**
    *   Convert a Date to a SQL Value String
    * 
    *   @param d  A date value to be converted
    * 
    *   @return  a String value represents a value formmatted as 'YYYY-MM-DD' and appended two quotation marks, null if input is null
    *
    */
   public static String  d2sql(Date d){
   	  	String s;
   	  	s		=CommonUtil.d2s(d);
   	  	if (s==null  ||  s==""){
   	  	  	s  =null;
   	  	}else{
   	  		s  	="'"+s+"'";	
   	  	}
   	  	
   	  	return s;
   }

   /**
    *   Convert a Datetime to a SQL Value String
    * 
    *   @param d  A datetime value to be converted
    * 
    *   @return  a String value represents a value formmatted as 'YYYY-MM-DD hh:mm:ss' and appended two quotation marks, null if input is null
    *
    */
   public static String  dt2sql(Date d){
   	  	String s;
   	  	s		=CommonUtil.dt2s(d);
   	  	if (s==null  ||  s==""){
   	  	  	s  =null;
   	  	}else{
   	  		s  	="'"+s+"'";	
   	  	}
   	  	
   	  	return s;
   }
 
		
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -