pubutil.java
来自「基于J2EE的办公自动化系统。实现流程定义流程办理等。运用了hibernate+」· Java 代码 · 共 83 行
JAVA
83 行
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 + =
减小字号Ctrl + -
显示快捷键?