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

📄 publicfuction.java

📁 基于中国网通cngp2.0开发的一个java网关源代码。大家多多公开SP类的网关程序哦
💻 JAVA
字号:
package cn.netjava.cngpclient.publics;import java.io.*;import java.util.*;/** * 常用工具方法集 * 中国网通短信网关客户端--蓝杰实训项目 * @author www.NetJava.cn * */public class PublicFuction {	public PublicFuction() {	}	public static int reTime() {		Calendar now = Calendar.getInstance();		int mm = now.get(Calendar.MINUTE);		int ss = now.get(Calendar.SECOND);		int ms = now.get(Calendar.MILLISECOND);		int hhffssms = mm * 60 * 1000 + ss * 1000 + ms;		return hhffssms;	}	public final static String getSysTime() {		Calendar now = Calendar.getInstance();		String yyyy = String.valueOf(now.get(Calendar.YEAR));		String mm = totwo(String.valueOf(now.get(Calendar.MONTH) + 1));		String dd = totwo(String.valueOf(now.get(Calendar.DAY_OF_MONTH)));		String hh = totwo(String.valueOf(now.get(Calendar.HOUR_OF_DAY)));		String ff = totwo(String.valueOf(now.get(Calendar.MINUTE)));		String ss = totwo(String.valueOf(now.get(Calendar.SECOND)));		return yyyy + "年" + mm + "月" + dd + "日" + hh + "时" + ff + "分" + ss				+ "秒";	}	public final static String getSysDate() {		Calendar now = Calendar.getInstance();		String yyyy = String.valueOf(now.get(Calendar.YEAR));		String mm = totwo(String.valueOf(now.get(Calendar.MONTH) + 1));		String dd = totwo(String.valueOf(now.get(Calendar.DAY_OF_MONTH)));		return yyyy + "年" + mm + "月" + dd + "日";	}	public final static int getCurrentTimeForUnionSeq() {		Calendar now = Calendar.getInstance();		int mm = now.get(Calendar.MONTH);		int dd = now.get(Calendar.DAY_OF_MONTH);		int hh = now.get(Calendar.HOUR_OF_DAY);		int mi = now.get(Calendar.MINUTE);		int ss = now.get(Calendar.SECOND);		int mmddhhmiss = mm * 100000000 + dd * 1000000 + hh * 10000 + mi * 100				+ ss;		return mmddhhmiss;	}	// public final static String getSysInfo()	// {	// return	// Integer.toString(com.aijian.sms.communication.ComConstants.o_IsmgInfo.spCode)+"2002年9月	// "+getSysTime();	// }	// public final static String getTelInfo()	// {	// return "客服热线:0731-2258386 客服传真:0731-2244986 客服经理电话:13874913777 刘小姐	// 客服E_Mail:online@Fox.com.cn 欢迎来电查询!(本条信息免费)";	// }	/**	 * 公有方法,产生与时间相关的字符串	 * 	 * @return String	 */	public static String reTime_id() {		Calendar now = Calendar.getInstance();		String nn = Integer.toString(now.get(Calendar.YEAR));		String mon = Integer.toString(now.get(Calendar.MONTH) + 1);		if (mon.length() == 1)			mon = "0" + mon;		String dd = Integer.toString(now.get(Calendar.DAY_OF_MONTH));		if (dd.length() == 1)			dd = "0" + dd;		String hh = Integer.toString(now.get(Calendar.HOUR_OF_DAY));		if (hh.length() == 1)			hh = "0" + hh;		// String ss = now.get(Calendar.SECOND);		// int ms = now.get(Calendar.MILLISECOND);		// int hhffssms =mm*60*1000+ss*1000+ms;		String nnmonddhh = nn + mon + dd + hh;		return nnmonddhh;	}	public static String getTimeStamp() {		Calendar now = Calendar.getInstance();		String mm = totwo(String.valueOf(now.get(Calendar.MONTH) + 1));		String dd = totwo(String.valueOf(now.get(Calendar.DAY_OF_MONTH)));		String hh = totwo(String.valueOf(now.get(Calendar.HOUR_OF_DAY)));		String ff = totwo(String.valueOf(now.get(Calendar.MINUTE)));		String ss = totwo(String.valueOf(now.get(Calendar.SECOND)));		return mm + dd + hh + ff + ss;	}	public static String totwo(String s) {		if (s.length() < 2) {			s = "0" + s;			return s;		}		return s;	}	/**	 * 公有方法,将当前时间格式化	 * 	 * @return String	 */	public static String formatDateTime() {		Calendar now = Calendar.getInstance();		String year = Integer.toString(now.get(Calendar.YEAR));		String mon = Integer.toString(now.get(Calendar.MONTH) + 1);		String day = Integer.toString(now.get(Calendar.DAY_OF_MONTH));		String hour = Integer.toString(now.get(Calendar.HOUR_OF_DAY));		String min = Integer.toString(now.get(Calendar.MINUTE));		String sec = Integer.toString(now.get(Calendar.SECOND));		mon = (mon.length() == 1) ? "0" + mon : mon;		day = (day.length() == 1) ? "0" + day : day;		hour = (hour.length() == 1) ? "0" + hour : hour;		min = (min.length() == 1) ? "0" + min : min;		sec = (sec.length() == 1) ? "0" + sec : sec;		return (year.substring(2, 4) + mon + day + hour + min + sec);	}	/**	 * 公有方法,线程休眠(单位:微秒)	 * 	 * @param miniSec	 */	public static void threadSleep(int miniSec) {		try {			Thread.sleep(miniSec);		} catch (InterruptedException e) {		}	}	/*	 * 把字符串数组用separator衔接为一个字符串 @param srcString 原字符串 @param separator 分隔符	 * @return 目的数组	 */	public static final String[] string2StringArray(String srcString,			String separator) {		int index = 0;		String[] temp;		StringTokenizer st = new StringTokenizer(srcString, separator);		temp = new String[st.countTokens()];		while (st.hasMoreTokens()) {			temp[index] = st.nextToken().trim();			index++;		}		return temp;	}}

⌨️ 快捷键说明

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