用Java开发的、实现类似Visio功能的应用程序源码

源代码在线查看: dbutil.java

软件大小: 7256 K
上传用户: thor
关键词: Visio Java 应用程序 源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				/**
				 *    $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;
				   }
				 
						
				    
				}			

相关资源