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

📄 pubutil.java

📁 基于J2EE的办公自动化系统。实现流程定义流程办理等。运用了hibernate+struts+spring框架综合运用的系统。
💻 JAVA
字号:
package com.oa.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/**
 * 公用工具类
 * @author ytl
 *
 */
public class PubUtil {
	
	/**
	 * 把当前日期转化为字符串,返回String数据类型
	 *  @param  date Date
	 *  @return simpleDateFormat.format(date) String
	 *  @return null String
	 */   
	public static String getNowDate(){   
		Date date = new Date();
		
		String SIMPLE_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";  
	    
		SimpleDateFormat simpleDateFormat;   
		  
		simpleDateFormat = new SimpleDateFormat(SIMPLE_DATE_FORMAT); 
		
		simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
		
	    return null==date?null:simpleDateFormat.format(date);   
	}   
	/**
	 * 获取以当前日期时间为数据的新编号,返回String数据类型
	 *  @param  date Date
	 *  @return simpleDateFormat.format(date) String
	 *  @return null String
	 */
	public static String getNewNo() {
		Date date = new Date();
		
		String SIMPLE_DATE_FORMAT = "yyyyMMddhhmmss";  
	    
		SimpleDateFormat simpleDateFormat;   
		  
		simpleDateFormat = new SimpleDateFormat(SIMPLE_DATE_FORMAT); 
		
		simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
		
	    return null==date?null:simpleDateFormat.format(date); 
	}
	
	/**
	 * 把字符串转化为double型,返回double数据类型
	 * @param str
	 * @return
	 */
	public static double parseDouble(String str){
		double result =0;
		try {
			result = Double.parseDouble(str);
		} catch (Exception e) {
			result =0;
		}
		return result;
	}
	
	/**
	 * 把字符串转化为int型,返回int数据类型
	 * @param str
	 * @return
	 */
	public static int parseInt(String str){
		int result =0;
		try {
			result = Integer.parseInt(str);
		} catch (Exception e) {
			result =0;
		}
		return result;
	}
	
}

⌨️ 快捷键说明

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