📄 utilities.java
字号:
package client.chaowei.intraweb.bean.util;
import java.util.Date;
import java.text.SimpleDateFormat;
import client.chaowei.intraweb.bean.data.*;
import java.net.*;
import java.io.*;
public class Utilities {
/**
* 为文件名添加时间标记,主要用于附件上传时防止文件重名
* @param fileName
* @return
*/
public String addTimeStampToFileName(String fileName) {
// 文件名称中扩展名前面的"."的位置
int dotIndex = fileName.lastIndexOf(".");
// 文件名称(不包括扩展名)
String firstPart = fileName.substring(0,dotIndex);
// 文件的扩展名
String secondPart = fileName.substring(dotIndex+1);
// 获取当前系统时间
Date d = new Date();
// 转换日期格式为:"yyyyMMddhhmmss"
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String now = sdf.format(d);
fileName = firstPart+now+"."+secondPart;
return fileName;
}
/**
* 获得指定用户ID的部门名称
* @param userId 用户ID
* @return 部门名称
*/
public String getOrg(String userId){
OracleConnection oraconn = new OracleConnection();
String sql = "select org from pa_emp_employee where id='"+userId+"'"; //查询id等于用户id的部门名称
String org = oraconn.getSnglRowSnglCol(sql,"org",0);
return org;
}
/**
*
*/
public String skyReport(String sTotalString) {
int firstPlace = sTotalString.indexOf("连云港市气象台");
int secPlace = sTotalString.indexOf("预报值班员");
String skyReport = sTotalString.substring(firstPlace,secPlace);
//skyReport.replaceAll("内部资料","");
//skyReport.replaceAll("海上大风警报","");
//skyReport.replaceAll("转发必究","");
//skyReport.replaceAll("───────────────────────","");
//skyReport.replaceAll("<br>","");
//skyReport.replaceAll(" ","");
skyReport = this.Replace(skyReport,"内部资料","");
skyReport = this.Replace(skyReport,"海上大风警报","");
skyReport = this.Replace(skyReport,"转发必究","");
skyReport = this.Replace(skyReport,"───────────────────────","");
skyReport = this.Replace(skyReport,"<br>","");
skyReport = this.Replace(skyReport," ","");
//skyReport.replace('chr(13)&chr(10)','\n');
return skyReport;
}
public static String Replace(String str, String oldWord, String newWord) {
String tempStr = new String(str);
int pos = tempStr.indexOf(oldWord);
while (pos > -1) {
tempStr = tempStr.substring(0, pos) + newWord +
tempStr.substring(pos + oldWord.length());
pos = tempStr.indexOf(oldWord, pos + newWord.length());
}
return tempStr;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -