?? publicfuction.java
字號:
package cn.netjava.cngpclient.publics;import java.io.*;import java.util.*;/** * 常用工具方法集 * 中國網(wǎng)通短信網(wǎng)關(guān)客戶端--藍(lán)杰實訓(xùn)項目 * @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 客服經(jīng)理電話:13874913777 劉小姐 // 客服E_Mail:online@Fox.com.cn 歡迎來電查詢!(本條信息免費)"; // } /** * 公有方法,產(chǎn)生與時間相關(guān)的字符串 * * @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; } /** * 公有方法,將當(dāng)前時間格式化 * * @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) { } } /* * 把字符串?dāng)?shù)組用separator銜接為一個字符串 @param srcString 原字符串 @param separator 分隔符 * @return 目的數(shù)組 */ 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; }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -