學(xué)習(xí) 學(xué)習(xí) 再學(xué)習(xí)

          學(xué)習(xí)才是唯一的出路

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            31 隨筆 :: 1 文章 :: 8 評(píng)論 :: 0 Trackbacks

          #

          ·               配置Eclipse

          1. 下載JDK:

          從sun的官網(wǎng)http://java.sun.com/javase/downloads/?intcmp=1281下載JDK,當(dāng)前最新版本是jdk-6u10-windows-i586-p.exe,這個(gè)是正式版的。

          1. 下載WTK:

          同時(shí)在sun的網(wǎng)站http://java.sun.com/products/sjwtoolkit/zh_download-2_5_2.html下載WTK,當(dāng)前最新版本是sun_java_wireless_toolkit-2_5_2-ml-windows.exe。

          1. 安裝JDK和WTK:

          先安裝JDK再安裝WTK,我的安裝路徑是:D:"Java"jdk1.6.0_10和D:"Java"WTK2.5.2

          1. 下載eclipse:

          從eclipse的官網(wǎng) http://www.eclipse.org/downloads/下載eclipse,我用的是:eclipse-java-ganymede-SR1-win32.zip,解壓到:XX:"eclipse

          1. 下載eclipseme:

          從eclipseme的官網(wǎng)   http://sourceforge.net/project/showfiles.php?group_id=86829下載eclipseme.當(dāng)前最新版本是eclipseeclipseme.feature_1.7.9_site.zip

          1. 配置eclipse:

          到 “首選項(xiàng)”找到,Java—>調(diào)試,將“發(fā)生未不捕獲到的異常時(shí)暫掛執(zhí)行”與“在發(fā)生編譯錯(cuò)誤時(shí)暫掛執(zhí)行”這兩個(gè)選項(xiàng)調(diào)為“未選中”狀態(tài),再把下面的調(diào)試器超時(shí)(毫秒)的右側(cè)數(shù)值設(shè)置為15000

          1. 配置eclipseME:

          運(yùn)行eclipse,配置自己學(xué)習(xí)的工作路徑,選擇 幫助—>軟件更新—>查找并安裝—>搜索要安裝的新功能部件,選擇 新建已歸檔的站點(diǎn),選擇eclipseme.feature_1.7.9_site.zip文件,安裝,重啟eclipse

          1. 配置WTK:

          選擇 首選項(xiàng)—>J2ME—>Device Management—>Import 在Specify search directory下,選擇你所裝的WTK模擬器的目錄;選擇 Refresh ,后按完成,使用DefaultColorPhone為默認(rèn)模式,這時(shí)已為eclipse配置上了模擬器

          1. 下載ProGuard:

          需要使用插件ProGuard,從ProGuard的官網(wǎng)下載ProGuard,當(dāng)前的最新版本是:proguard4.3beta2.tar.gz,解壓到:XX:"proguard4.3

          1. 配置ProGuard:

          到 Eclipse的“首選項(xiàng)”找到,J2ME—>Packaging—>obfuscation,在Proguard Root Directory右邊的框中,選擇剛才解壓的proguard4.3的文件夾(XX:"proguard4.3),點(diǎn)擊應(yīng)用,這時(shí)為eclipse配置上了混淆器

          1. 配置完畢

          ·               使用eclipse進(jìn)行J2ME開發(fā)

          1. 新建 J2ME下的J2ME Midlet Suite,填寫項(xiàng)目名,下一步,完成
          2. 新建 J2ME下的J2ME Midlet,填寫名稱,完成
          3. 點(diǎn)擊運(yùn)行,新建一個(gè)Wireless Toolkit Emulator的運(yùn)行配置,運(yùn)行,出現(xiàn)手機(jī)樣式,運(yùn)行成功
          posted @ 2009-10-25 19:54 鐵猴 閱讀(389) | 評(píng)論 (0)編輯 收藏

          import java.net.URL;
          import java.util.Vector;
          import org.apache.soap.Constants;
          import org.apache.soap.Fault;
          import org.apache.soap.SOAPException;
          import org.apache.soap.encoding.SOAPMappingRegistry;
          import org.apache.soap.encoding.soapenc.BeanSerializer;
          import org.apache.soap.rpc.Call;
          import org.apache.soap.rpc.Parameter;
          import org.apache.soap.rpc.Response;
          import org.apache.soap.transport.http.SOAPHTTPConnection;
          import org.apache.soap.util.xml.QName;
          import org.w3c.dom.Element;
          import org.w3c.dom.Node;
          import oss.util.debug.LogHome;

          public class GisWebService{
           
           public static String getStringGisWebService(String ajfBm, String zjfBm, String aodfBm,String zodfBm) throws Exception {
            String strUrl = "   String strTargetURL = "http://java.sun.com/xml/ns/jax-rpc/ri/config";//
            String soapAction = "      URL url = new URL(strUrl);
               SOAPMappingRegistry smr = new SOAPMappingRegistry();
               BeanSerializer beanSer = new BeanSerializer();
               smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("","Result"),null,null,beanSer);
               Call call = new Call();
               SOAPHTTPConnection st = new SOAPHTTPConnection();
               call.setSOAPTransport(st);
               call.setSOAPMappingRegistry(smr);
               call.setTargetObjectURI(strTargetURL);
               call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
               call.setParams(createCondition(ajfBm,zjfBm,aodfBm,zodfBm));
               call.setMethodName("WSEncrypt"); //調(diào)用WEBSERVICE方法名
               Response resp;
               try
               {
                 call.setTimeout(3000);
                 resp = call.invoke(url,soapAction);
               }
               catch(SOAPException e)
               {
                 throw new Exception("調(diào)用接口出錯(cuò)!URL="+strUrl+"\n"+e.getMessage());
               }
               LogHome.getLog().info("調(diào)用成功,開始接收返回信息!");

               return returnValue(resp);
           }
           
           public static String returnValue(Response resp) throws Exception {
            if(resp.generatedFault()) {
                  Fault fault = resp.getFault();
                  String code = fault.getFaultCode();
                  String desc = fault.getFaultString();
                  LogHome.getLog().info("Fault code:"+code+":"+desc);
                  Vector v = fault.getDetailEntries();
                  int cnt = v.size();
                  for(int i = 0;i<cnt;i++)
                  {
                    Element n = (Element)v.elementAt(i);
                    Node nd = n.getFirstChild();
                    LogHome.getLog().info("Each element:"+n.getNodeName()+":"+nd.getNodeValue());
                  }
                  throw new Exception("調(diào)用接口時(shí)出錯(cuò),F(xiàn)ault code:"+code+":"+desc);
                }
                else
                {
                  Parameter ret = resp.getReturnValue();
                  String returnXML = (String)ret.getValue();
                  LogHome.getLog().info(returnXML);
                  return returnXML;
                }
           }
           
           public static  Vector<Parameter> createCondition(String ajfBm,String zjfBm,String aodfBm,String zodfBm) {
             Vector<Parameter> params = new Vector<Parameter>();
               params.addElement(new Parameter("AjfBm",String.class,ajfBm,null));
               params.addElement(new Parameter("ZjfBm",String.class,zjfBm,null));
               params.addElement(new Parameter("AodfBm",String.class,aodfBm,null));
               params.addElement(new Parameter("ZodfBm",String.class,zodfBm,null));
               return params;
           }
           
          }


          public static Date getNowDate() {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            String dateString = formatter.format(currentTime);

            ParsePosition pos = new ParsePosition(8);

            Date currentTime_2 = formatter.parse(dateString, pos);

            return currentTime_2;

           }

           /**

            * 獲取現(xiàn)在時(shí)間

            *

            * @return返回短時(shí)間格式 yyyy-MM-dd

            */

           public static Date getNowDateShort() {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            String dateString = formatter.format(currentTime);

            ParsePosition pos = new ParsePosition(8);

            Date currentTime_2 = formatter.parse(dateString, pos);

            return currentTime_2;

           }

           /**

            * 獲取現(xiàn)在時(shí)間

            *

            * @return返回字符串格式 yyyy-MM-dd HH:mm:ss

            */

           public static String getStringDate() {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            String dateString = formatter.format(currentTime);

            return dateString;

           }

           /**

            * 獲取現(xiàn)在時(shí)間

            *

            * @return 返回短時(shí)間字符串格式y(tǒng)yyy-MM-dd

            */

           public static String getStringDateShort() {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            String dateString = formatter.format(currentTime);

            return dateString;

           }

           /**

            * 獲取時(shí)間 小時(shí):分;秒 HH:mm:ss

            *

            * @return

            */

           public static String getTimeShort() {

            SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");

            Date currentTime = new Date();

            String dateString = formatter.format(currentTime);

            return dateString;

           }

           /**

            * 將長時(shí)間格式字符串轉(zhuǎn)換為時(shí)間 yyyy-MM-dd HH:mm:ss

            *

            * @param strDate

            * @return

            */

           public static Date strToDateLong(String strDate) {

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            ParsePosition pos = new ParsePosition(0);

            Date strtodate = formatter.parse(strDate, pos);

            return strtodate;

           }

           /**

            * 將長時(shí)間格式時(shí)間轉(zhuǎn)換為字符串 yyyy-MM-dd HH:mm:ss

            *

            * @param dateDate

            * @return

            */

           public static String dateToStrLong(java.util.Date dateDate) {

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            String dateString = formatter.format(dateDate);

            return dateString;

           }

           /**

            * 將短時(shí)間格式時(shí)間轉(zhuǎn)換為字符串 yyyy-MM-dd

            *

            * @param dateDate

            * @param k

            * @return

            */

           public static String dateToStr(java.util.Date dateDate) {

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            String dateString = formatter.format(dateDate);

            return dateString;

           }

           /**

            * 將短時(shí)間格式字符串轉(zhuǎn)換為時(shí)間 yyyy-MM-dd

            *

            * @param strDate

            * @return

            */

           public static Date strToDate(String strDate) {

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            ParsePosition pos = new ParsePosition(0);

            Date strtodate = formatter.parse(strDate, pos);

            return strtodate;

           }

           /**

            * 得到現(xiàn)在時(shí)間

            *

            * @return

            */

           public static Date getNow() {

            Date currentTime = new Date();

            return currentTime;

           }

           /**

            * 提取一個(gè)月中的最后一天

            *

            * @param day

            * @return

            */

           public static Date getLastDate(long day) {

            Date date = new Date();

            long date_3_hm = date.getTime() - 3600000 * 34 * day;

            Date date_3_hm_date = new Date(date_3_hm);

            return date_3_hm_date;

           }

           /**

            * 得到現(xiàn)在時(shí)間

            *

            * @return 字符串 yyyyMMdd HHmmss

            */

           public static String getStringToday() {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd HHmmss");

            String dateString = formatter.format(currentTime);

            return dateString;

           }

           /**

            * 得到現(xiàn)在小時(shí)

            */

           public static String getHour() {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            String dateString = formatter.format(currentTime);

            String hour;

            hour = dateString.substring(11, 13);

            return hour;

           }

           /**

            * 得到現(xiàn)在分鐘

            *

            * @return

            */

           public static String getTime() {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            String dateString = formatter.format(currentTime);

            String min;

            min = dateString.substring(14, 16);

            return min;

           }

           /**

            * 根據(jù)用戶傳入的時(shí)間表示格式,返回當(dāng)前時(shí)間的格式 如果是yyyyMMdd,注意字母y不能大寫。

            *

            * @param sformat

            *            yyyyMMddhhmmss

            * @return

            */

           public static String getUserDate(String sformat) {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat(sformat);

            String dateString = formatter.format(currentTime);

            return dateString;

           }

           /**

            * 二個(gè)小時(shí)時(shí)間間的差值,必須保證二個(gè)時(shí)間都是"HH:MM"的格式,返回字符型的分鐘

            */

           public static String getTwoHour(String st1, String st2) {

            String[] kk = null;

            String[] jj = null;

            kk = st1.split(":");

            jj = st2.split(":");

            if (Integer.parseInt(kk[0]) < Integer.parseInt(jj[0]))

             return "0";

            else {

             double y = Double.parseDouble(kk[0]) + Double.parseDouble(kk[1]) / 60;

             double u = Double.parseDouble(jj[0]) + Double.parseDouble(jj[1]) / 60;

             if ((y - u) > 0)

              return y - u + "";

             else

              return "0";

            }

           }

           /**

            * 得到二個(gè)日期間的間隔天數(shù)

            */

           public static String getTwoDay(String sj1, String sj2) {

            SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");

            long day = 0;

            try {

             java.util.Date date = myFormatter.parse(sj1);

             java.util.Date mydate = myFormatter.parse(sj2);

             day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);

            } catch (Exception e) {

             return "";

            }

            return day + "";

           }

           /**

            * 時(shí)間前推或后推分鐘,其中JJ表示分鐘.

            */

           public static String getPreTime(String sj1, String jj) {

            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            String mydate1 = "";

            try {

             Date date1 = format.parse(sj1);

             long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;

             date1.setTime(Time * 1000);

             mydate1 = format.format(date1);

            } catch (Exception e) {

            }

            return mydate1;

           }

           /**

            * 得到一個(gè)時(shí)間延后或前移幾天的時(shí)間,nowdate為時(shí)間,delay為前移或后延的天數(shù)

            */

           public static String getNextDay(String nowdate, String delay) {

            try{

            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

            String mdate = "";

            Date d = strToDate(nowdate);

            long myTime = (d.getTime() / 1000) + Integer.parseInt(delay) * 24 * 60 * 60;

            d.setTime(myTime * 1000);

            mdate = format.format(d);

            return mdate;

            }catch(Exception e){

             return "";

            }

           }

           /**

            * 判斷是否潤年

            *

            * @param ddate

            * @return

            */

           public static boolean isLeapYear(String ddate) {

            /**

             * 詳細(xì)設(shè)計(jì): 1.被400整除是閏年,否則: 2.不能被4整除則不是閏年 3.能被4整除同時(shí)不能被100整除則是閏年

             * 3.能被4整除同時(shí)能被100整除則不是閏年

             */

            Date d = strToDate(ddate);

            GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();

            gc.setTime(d);

            int year = gc.get(Calendar.YEAR);

            if ((year % 400) == 0)

             return true;

            else if ((year % 4) == 0) {

             if ((year % 100) == 0)

              return false;

             else

              return true;

            } else

             return false;

           }

           /**

            * 返回美國時(shí)間格式 26 Apr 2006

            *

            * @param str

            * @return

            */

           public static String getEDate(String str) {

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            ParsePosition pos = new ParsePosition(0);

            Date strtodate = formatter.parse(str, pos);

            String j = strtodate.toString();

            String[] k = j.split(" ");

            return k[2] + k[1].toUpperCase() + k[5].substring(2, 4);

           }

           /**

            * 獲取一個(gè)月的最后一天

            *

            * @param dat

            * @return

            */

           public static String getEndDateOfMonth(String dat) {// yyyy-MM-dd

            String str = dat.substring(0, 8);

            String month = dat.substring(5, 7);

            int mon = Integer.parseInt(month);

            if (mon == 1 || mon == 3 || mon == 5 || mon == 7 || mon == 8 || mon == 10 || mon == 12) {

             str += "31";

            } else if (mon == 4 || mon == 6 || mon == 9 || mon == 11) {

             str += "30";

            } else {

             if (isLeapYear(dat)) {

              str += "29";

             } else {

              str += "28";

             }

            }

            return str;

           }

           /**

            * 判斷二個(gè)時(shí)間是否在同一個(gè)周

            *

            * @param date1

            * @param date2

            * @return

            */

           public static boolean isSameWeekDates(Date date1, Date date2) {

            Calendar cal1 = Calendar.getInstance();

            Calendar cal2 = Calendar.getInstance();

            cal1.setTime(date1);

            cal2.setTime(date2);

            int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);

            if (0 == subYear) {

             if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))

              return true;

            } else if (1 == subYear && 11 == cal2.get(Calendar.MONTH)) {

             // 如果12月的最后一周橫跨來年第一周的話則最后一周即算做來年的第一周

             if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))

              return true;

            } else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH)) {

             if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))

              return true;

            }

            return false;

           }

           /**

            * 產(chǎn)生周序列,即得到當(dāng)前時(shí)間所在的年度是第幾周

            *

            * @return

            */

           public static String getSeqWeek() {

            Calendar c = Calendar.getInstance(Locale.CHINA);

            String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));

            if (week.length() == 1)

             week = "0" + week;

            String year = Integer.toString(c.get(Calendar.YEAR));

            return year + week;

           }

           /**

            * 獲得一個(gè)日期所在的周的星期幾的日期,如要找出2002年2月3日所在周的星期一是幾號(hào)

            *

            * @param sdate

            * @param num

            * @return

            */

           public static String getWeek(String sdate, String num) {

            // 再轉(zhuǎn)換為時(shí)間

            Date dd = VeDate.strToDate(sdate);

            Calendar c = Calendar.getInstance();

            c.setTime(dd);

            if (num.equals("1")) // 返回星期一所在的日期

             c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

            else if (num.equals("2")) // 返回星期二所在的日期

             c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);

            else if (num.equals("3")) // 返回星期三所在的日期

             c.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);

            else if (num.equals("4")) // 返回星期四所在的日期

             c.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);

            else if (num.equals("5")) // 返回星期五所在的日期

             c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);

            else if (num.equals("6")) // 返回星期六所在的日期

             c.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);

            else if (num.equals("0")) // 返回星期日所在的日期

             c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);

            return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());

           }

           /**

            * 根據(jù)一個(gè)日期,返回是星期幾的字符串

            *

            * @param sdate

            * @return

            */

           public static String getWeek(String sdate) {

            // 再轉(zhuǎn)換為時(shí)間

            Date date = VeDate.strToDate(sdate);

            Calendar c = Calendar.getInstance();

            c.setTime(date);

            // int hour=c.get(Calendar.DAY_OF_WEEK);

            // hour中存的就是星期幾了,其范圍 1~7

            // 1=星期日 7=星期六,其他類推

            return new SimpleDateFormat("EEEE").format(c.getTime());

           }

           public static String getWeekStr(String sdate){

            String str = "";

            str = VeDate.getWeek(sdate);

            if("1".equals(str)){

             str = "星期日";

            }else if("2".equals(str)){

             str = "星期一";

            }else if("3".equals(str)){

             str = "星期二";

            }else if("4".equals(str)){

             str = "星期三";

            }else if("5".equals(str)){

             str = "星期四";

            }else if("6".equals(str)){

             str = "星期五";

            }else if("7".equals(str)){

             str = "星期六";

            }

            return str;

           }

           /**

            * 兩個(gè)時(shí)間之間的天數(shù)

            *

            * @param date1

            * @param date2

            * @return

            */

           public static long getDays(String date1, String date2) {

            if (date1 == null || date1.equals(""))

             return 0;

            if (date2 == null || date2.equals(""))

             return 0;

            // 轉(zhuǎn)換為標(biāo)準(zhǔn)時(shí)間

            SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");

            java.util.Date date = null;

            java.util.Date mydate = null;

            try {

             date = myFormatter.parse(date1);

             mydate = myFormatter.parse(date2);

            } catch (Exception e) {

            }

            long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);

            return day;

           }

           /**

            * 形成如下的日歷 , 根據(jù)傳入的一個(gè)時(shí)間返回一個(gè)結(jié)構(gòu) 星期日 星期一 星期二 星期三 星期四 星期五 星期六 下面是當(dāng)月的各個(gè)時(shí)間

            * 此函數(shù)返回該日歷第一行星期日所在的日期

            *

            * @param sdate

            * @return

            */

           public static String getNowMonth(String sdate) {

            // 取該時(shí)間所在月的一號(hào)

            sdate = sdate.substring(0, 8) + "01";

            // 得到這個(gè)月的1號(hào)是星期幾

            Date date = VeDate.strToDate(sdate);

            Calendar c = Calendar.getInstance();

            c.setTime(date);

            int u = c.get(Calendar.DAY_OF_WEEK);

            String newday = VeDate.getNextDay(sdate, (1 - u) + "");

            return newday;

           }

           /**

            * 取得數(shù)據(jù)庫主鍵 生成格式為yyyymmddhhmmss+k位隨機(jī)數(shù)

            *

            * @param k

            *            表示是取幾位隨機(jī)數(shù),可以自己定

            */

           public static String getNo(int k) {

            return getUserDate("yyyyMMddhhmmss") + getRandom(k);

           }

           /**

            * 返回一個(gè)隨機(jī)數(shù)

            *

            * @param i

            * @return

            */

           public static String getRandom(int i) {

            Random jjj = new Random();

            // int suiJiShu = jjj.nextInt(9);

            if (i == 0)

             return "";

            String jj = "";

            for (int k = 0; k < i; k++) {

             jj = jj + jjj.nextInt(9);

            }

            return jj;

           }

           /**

            *

            * @param args

            */

           public static boolean RightDate(String date) {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

            ;

            if (date == null)

             return false;

            if (date.length() > 10) {

             sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

            } else {

             sdf = new SimpleDateFormat("yyyy-MM-dd");

            }

            try {

             sdf.parse(date);

            } catch (ParseException pe) {

             return false;

            }

            return true;

           }

           /***************************************************************************

            * //nd=1表示返回的值中包含年度 //yf=1表示返回的值中包含月份 //rq=1表示返回的值中包含日期 //format表示返回的格式 1

            * 以年月日中文返回 2 以橫線-返回 // 3 以斜線/返回 4 以縮寫不帶其它符號(hào)形式返回 // 5 以點(diǎn)號(hào).返回

            **************************************************************************/

           public static String getStringDateMonth(String sdate, String nd, String yf, String rq, String format) {

            Date currentTime = new Date();

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            String dateString = formatter.format(currentTime);

            String s_nd = dateString.substring(0, 4); // 年份

            String s_yf = dateString.substring(5, 7); // 月份

            String s_rq = dateString.substring(8, 10); // 日期

            String sreturn = "";

            roc.util.MyChar mc = new roc.util.MyChar();

            if (sdate == null || sdate.equals("") || !mc.Isdate(sdate)) { // 處理空值情況

             if (nd.equals("1")) {

              sreturn = s_nd;

              // 處理間隔符

              if (format.equals("1"))

               sreturn = sreturn + "年";

              else if (format.equals("2"))

               sreturn = sreturn + "-";

              else if (format.equals("3"))

               sreturn = sreturn + "/";

              else if (format.equals("5"))

               sreturn = sreturn + ".";

             }

             // 處理月份

             if (yf.equals("1")) {

              sreturn = sreturn + s_yf;

              if (format.equals("1"))

               sreturn = sreturn + "月";

              else if (format.equals("2"))

               sreturn = sreturn + "-";

              else if (format.equals("3"))

               sreturn = sreturn + "/";

              else if (format.equals("5"))

               sreturn = sreturn + ".";

             }

             // 處理日期

             if (rq.equals("1")) {

              sreturn = sreturn + s_rq;

              if (format.equals("1"))

               sreturn = sreturn + "日";

             }

            } else {

             // 不是空值,也是一個(gè)合法的日期值,則先將其轉(zhuǎn)換為標(biāo)準(zhǔn)的時(shí)間格式

             sdate = roc.util.RocDate.getOKDate(sdate);

             s_nd = sdate.substring(0, 4); // 年份

             s_yf = sdate.substring(5, 7); // 月份

             s_rq = sdate.substring(8, 10); // 日期

             if (nd.equals("1")) {

              sreturn = s_nd;

              // 處理間隔符

              if (format.equals("1"))

               sreturn = sreturn + "年";

              else if (format.equals("2"))

               sreturn = sreturn + "-";

              else if (format.equals("3"))

               sreturn = sreturn + "/";

              else if (format.equals("5"))

               sreturn = sreturn + ".";

             }

             // 處理月份

             if (yf.equals("1")) {

              sreturn = sreturn + s_yf;

              if (format.equals("1"))

               sreturn = sreturn + "月";

              else if (format.equals("2"))

               sreturn = sreturn + "-";

              else if (format.equals("3"))

               sreturn = sreturn + "/";

              else if (format.equals("5"))

               sreturn = sreturn + ".";

             }

             // 處理日期

             if (rq.equals("1")) {

              sreturn = sreturn + s_rq;

              if (format.equals("1"))

               sreturn = sreturn + "日";

             }

            }

            return sreturn;

           }

           public static String getNextMonthDay(String sdate, int m) {

            sdate = getOKDate(sdate);

            int year = Integer.parseInt(sdate.substring(0, 4));

            int month = Integer.parseInt(sdate.substring(5, 7));

            month = month + m;

            if (month < 0) {

             month = month + 12;

             year = year - 1;

            } else if (month > 12) {

             month = month - 12;

             year = year + 1;

            }

            String smonth = "";

            if (month < 10)

             smonth = "0" + month;

            else

             smonth = "" + month;

            return year + "-" + smonth + "-10";

           }

           public static String getOKDate(String sdate) {

            if (sdate == null || sdate.equals(""))

             return getStringDateShort();

            if (!VeStr.Isdate(sdate)) {

             sdate = getStringDateShort();

            }

            // 將“/”轉(zhuǎn)換為“-”

            sdate = VeStr.Replace(sdate, "/", "-");

            // 如果只有8位長度,則要進(jìn)行轉(zhuǎn)換

            if (sdate.length() == 8)

             sdate = sdate.substring(0, 4) + "-" + sdate.substring(4, 6) + "-" + sdate.substring(6, 8);

            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            ParsePosition pos = new ParsePosition(0);

            Date strtodate = formatter.parse(sdate, pos);

            String dateString = formatter.format(strtodate);

            return dateString;

           }

           public static void main(String[] args) throws Exception {

            try {

             //System.out.print(Integer.valueOf(getTwoDay("2006-11-03 12:22:10", "2006-11-02 11:22:09")));

            } catch (Exception e) {

             throw new Exception();

            }

            //System.out.println("sss");

           }

          }   

          posted @ 2009-10-17 15:16 鐵猴 閱讀(2387) | 評(píng)論 (0)編輯 收藏

          ******************使用到的軟件******************

          IIS 6.0

          PHP 5.26

          MySQL V5.0.15 正式版

          phpMyAdmin-2.11.7-all-languages

          本機(jī)操作系統(tǒng) Window Server 2003 EnterPrise Edition SP2

          ******************使用到的軟件******************

          一直都是用的APPServ 突然覺得經(jīng)常用也沒有什么意思!于是就想自己配的玩下!這里使用的是IIS下配置。

          安裝IIS服務(wù)器

          打開控制面板->添加刪除程序->添加刪除組件->應(yīng)用程序服務(wù)器 要使用ASP.NET的就把詳細(xì)信息里面的ASP.NET勾上!然后下一步。

          這里如果有光盤的可以直接用光盤安裝,如果沒有就下一個(gè),我用的是IIS6 然后安裝的時(shí)候會(huì)提示你插入光盤,你瀏覽到下載解壓后的IIS6的文件里,然后會(huì)找到所需文件,就這樣一直瀏覽就可以安裝成功!

          安裝PHP

          安裝好IIS之后就需要打開準(zhǔn)備好的PHP文件,將里面的DLL文件全部復(fù)制到System 32 目錄下, 其實(shí)并不需要全部復(fù)制!只需要復(fù)制 php5ts.dll libmysql.dll libmcrypt.dll 這三個(gè)就行了!但如果你覺得不好記,全部復(fù)制進(jìn)去不會(huì)影響什么!然后將PHP目錄下的php.ini-recommended拷到C:\Windows下 然后把php.ini-recommended文件改名成php.ini

          從IIS里面添加對(duì)PHP的映射

          打開 Internet 信息服務(wù)(IIS)管理器(管理工具里面)

          點(diǎn)擊Web 服務(wù)擴(kuò)展 如果你同時(shí)要使用ASP ASP.NET(安裝了才有) 的話 就點(diǎn)擊左邊的允許! 同時(shí)所有未知的ISAPI也要允許!



          接著在默認(rèn)網(wǎng)站上--->右鍵--->屬性--->ISAPI 添加 篩選器,名稱 可以寫PHP 可執(zhí)行文件 找到 你的PHP目錄下的php5isapi.dll

          然后在點(diǎn)擊主目錄--->配置--->添加--->可執(zhí)行文件也選擇剛才這個(gè)文件 擴(kuò)展名填寫.php 確定

          同時(shí)在文檔里面可以添加index.php 這個(gè)是默認(rèn)打開的頁面!不會(huì)影響程序。如果你設(shè)置了它就自動(dòng)尋找這個(gè)文件,如果有就直接打開。不過還是建議添加一下!

          接下來 應(yīng)用 確定 重啟IIS服務(wù)

          重啟方法:

          在運(yùn)行里面依次輸入

          net stop w3svc

          net stop iisadmin

          net start w3svc

          接著在你的目錄下的PHP文件就可以瀏覽了!

          比如輸入

          echo phpinfo();

          ?>

          短標(biāo)記默認(rèn)是關(guān)閉的,請(qǐng)寫成這種形式的,建議不使用短標(biāo)記。

          保存為index.php,然后在Internet 信息服務(wù)(IIS)管理器下的默認(rèn)網(wǎng)站的右邊 點(diǎn)擊你想看的頁面 右鍵 瀏覽!OK 顯示出來了。

          配置PHP

          上面僅僅完成了PHP的安裝,但是PHP的配置都是默認(rèn)的,這樣子會(huì)帶來很多的問題。為了使PHP能更好的運(yùn)行,需要修改PHP配置!PHP主要與php.ini有關(guān),打開C:\Windows下的php.ini。

          找到 extension_dir = "./" 改成extension_dir = "C:\php\ext\" 地址是PHP目錄下的ext文件夾,

          posted @ 2009-10-15 19:34 鐵猴 閱讀(209) | 評(píng)論 (0)編輯 收藏

          SELECT  a.title,a.SEND_STAFF_ID,a.SEND_DATE,a.STATE,a.order_id
          from order_main_info a,INT_AD_INFO  c
          WHERE   a.order_type='32' and
          a.state='0' and c.order_id=a.order_id and
          a.order_id=(select order_id from(select rownum rn,order_id
          from ORDER_DEAL_INFO where order_id=(select order_id from order_main_info where order_type='32' and  state='0'))
          where rn=(select count(*) from ORDER_DEAL_INFO where order_id=(select order_id from order_main_info where order_type='32' and  state='0')))
          posted @ 2009-10-15 09:36 鐵猴 閱讀(172) | 評(píng)論 (0)編輯 收藏

          3.7 復(fù)選框的全選,多選,全不選,反選
          <form name=hrong>
          <input type=checkbox name=All onclick="checkAll('mm')">全選<br/>
          <input type=checkbox name=mm onclick="checkItem('All')"><br/>
          <input type=checkbox name=mm onclick="checkItem('All')"><br/>
          <input type=checkbox name=mm onclick="checkItem('All')"><br/>
          <input type=checkbox name=mm onclick="checkItem('All')"><br/>
          <input type=checkbox name=mm onclick="checkItem('All')"><br/><br/>


          <input type=checkbox name=All2 onclick="checkAll('mm2')">全選<br/>
          <input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
          <input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
          <input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
          <input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
          <input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>

          </form>

          <SCRIPT LANGUAGE="JavaScript">
          function checkAll(str)
          {
             var a = document.getElementsByName(str);
             var n = a.length;
             for (var i=0; i<n; i++)
             a[i].checked = window.event.srcElement.checked;
          }
          function checkItem(str)
          {
             var e = window.event.srcElement;
             var all = eval("document.hrong."+ str);
             if (e.checked)
             {
               var a = document.getElementsByName(e.name);
               all.checked = true;
               for (var i=0; i<a.length; i++)
               {
                 if (!a[i].checked){ all.checked = false; break;}
               }
             }
             else all.checked = false;
          }
          </SCRIPT>

          3.8 文件上傳過程中判斷文件類型
          <input type=file onchange="alert(this.value.match(/^(.*)(\.)(.{1,8})$/)[3])">

          畫圖:
          <OBJECT
          id=S
          style="LEFT: 0px; WIDTH: 392px; TOP: 0px; HEIGHT: 240px"
          height=240
          width=392
          classid="clsid:369303C2-D7AC-11D0-89D5-00A0C90833E6">
          </OBJECT>
          <SCRIPT>
          S.DrawingSurface.ArcDegrees(0,0,0,30,50,60);
          S.DrawingSurface.ArcRadians(30,0,0,30,50,60);
          S.DrawingSurface.Line(10,10,100,100);
          </SCRIPT>

          寫注冊表:
          <SCRIPT>
          var WshShell = WScript.CreateObject("WScript.Shell");
          WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\", 1, "REG_BINARY");
          WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader", "Goocher!", "REG_SZ");
          var bKey =     WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\");
          WScript.Echo (WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader"));
          WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader");
          WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\");
          WshShell.RegDelete ("HKCU\\Software\\ACME\\");
          </SCRIPT>

          TABLAE相關(guān)(客戶端動(dòng)態(tài)增加行列)
          <HTML>
          <SCRIPT LANGUAGE="JScript">
          function numberCells() {
               var count=0;
               for (i=0; i < document.all.mytable.rows.length; i++) {
                   for (j=0; j < document.all.mytable.rows(i).cells.length; j++) {
                       document.all.mytable.rows(i).cells(j).innerText = count;
                       count++;
                   }
               }
          }
          </SCRIPT>
          <BODY onload="numberCells()">
          <TABLE id=mytable border=1>
          <TR><TH> </TH><TH> </TH><TH> </TH><TH> </TH></TR>
          <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR>
          <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR>
          </TABLE>
          </BODY>
          </HTML>

          1.身份證嚴(yán)格驗(yàn)證:

          <script>
          var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"內(nèi)蒙古",21:"遼寧",22:"吉林",23:"黑龍江",31:"上海",32:"江蘇",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山東",41:"河南",42:"湖北",43:"湖南",44:"廣東",45:"廣西",46:"海南",50:"重慶",51:"四川",52:"貴州",53:"云南",54:"西藏",61:"陜西",62:"甘肅",63:"青海",64:"寧夏",65:"新疆",71:"臺(tái)灣",81:"香港",82:"澳門",91:"國外"}
            
          function cidInfo(sId){
          var iSum=0
          var info=""
          if(!/^\d{17}(\d|x)$/i.test(sId))return false;
          sId=sId.replace(/x$/i,"a");
          if(aCity[parseInt(sId.substr(0,2))]==null)return "Error:非法地區(qū)";
          sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
          var d=new Date(sBirthday.replace(/-/g,"/"))
          if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return "Error:非法生日";
          for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)
          if(iSum%11!=1)return "Error:非法證號(hào)";
          return aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女")
          }

          document.write(cidInfo("380524198002300016"),"<br/>");
          document.write(cidInfo("340524198002300019"),"<br/>")
          document.write(cidInfo("340524197711111111"),"<br/>")
          document.write(cidInfo("34052419800101001x"),"<br/>");
          </script>

          2.驗(yàn)證IP地址
          <SCRIPT LANGUAGE="JavaScript">
          function isip(s){
          var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}};
          var re=s.split(".")
          return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):false
          }

          var s="202.197.78.129";
          alert(isip(s))
          </SCRIPT>



          3.加sp1后還能用的無邊框窗口!!
          <HTML XMLNS:IE>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <IE:Download ID="include" STYLE="behavior:url(#default#download)" />
          <title>Chromeless Window</title>

          <SCRIPT LANGUAGE="JScript">
          /*--- Special Thanks For andot ---*/

          /*
          This following code are designed and writen by Windy_sk <seasonx@163.net>
          You can use it freely, but u must held all the copyright items!
          */

          /*--- Thanks For andot Again ---*/

          var CW_width = 400;
          var CW_height = 300;
          var CW_top = 100;
          var CW_left = 100;
          var CW_url = "/";
          var New_CW = window.createPopup();
          var CW_Body = New_CW.document.body;
          var content = "";
          var CSStext = "margin:1px;color:black; border:2px outset;border-style:e­xpression(onmouseout=onmouseup=function(){this.style.borderStyle='outset'}, onmousedown=function(){if(event.button!=2)this.style.borderStyle='inset'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursor:Default;";

          //Build Window
          include.startDownload(CW_url, function(source){content=source});

          function insert_content(){
          var temp = "";
          CW_Body.style.overflow   = "hidden";
          CW_Body.style.backgroundColor = "white";
          CW_Body.style.border   =   "solid black 1px";
          content = content.replace(/<a ([^>]*)>/g,"<a onclick='parent.open(this.href);return false' $1>");
          temp += "<table width=100% height=100% cellpadding=0 cellspacing=0 border=0>";
          temp += "<tr style=';font-size:12px;background:#0099CC;height:20;cursor:default' ondblclick=\"Max.innerText=Max.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\" onmouseup='parent.drag_up(event)' onmousemove='parent.drag_move(event)' onmousedown='parent.drag_down(event)' onselectstart='return false' oncontextmenu='return false'>";
          temp += "<td style='color:#ffffff;padding-left:5px'>Chromeless Window For IE6 SP1</td>";
          temp += "<td style='color:#ffffff;padding-right:5px;' align=right>";
          temp += "<span id=Help   onclick=\"alert('Chromeless Window For IE6 SP1   -   Ver 1.0\\n\\nCode By Windy_sk\\n\\nSpecial Thanks For andot')\" style=\""+CSStext+"font-family:System;padding-right:2px;\">?</span>";
          temp += "<span id=Min   onclick='parent.New_CW.hide();parent.blur()' style=\""+CSStext+"font-family:Webdings;\" title='Minimum'>0</span>";
          temp += "<span id=Max   onclick=\"this.innerText=this.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\" style=\""+CSStext+"font-family:Webdings;\" title='Maximum'>1</span>";
          temp += "<span id=Close onclick='parent.opener=null;parent.close()' style=\""+CSStext+"font-family:System;padding-right:2px;\" title='Close'>x</span>";
          temp += "</td></tr><tr><td colspan=2>";
          temp += "<div id=include style='overflow:scroll;overflow-x:hidden;overflow-y:auto; HEIGHT: 100%; width:"+CW_width+"'>";
          temp += content;
          temp += "</div>";
          temp += "</td></tr></table>";
          CW_Body.innerHTML = temp;
          }

          setTimeout("insert_content()",1000);

          var if_max = true;
          function show_CW(){
          window.moveTo(10000, 10000);
          if(if_max){
             New_CW.show(CW_top, CW_left, CW_width, CW_height);
             if(typeof(New_CW.document.all.include)!="undefined"){
             New_CW.document.all.include.style.width = CW_width;
             New_CW.document.all.Max.innerText = "1";
             }
            
          }else{
             New_CW.show(0, 0, screen.width, screen.height);
             New_CW.document.all.include.style.width = screen.width;
          }
          }

          window.onfocus   = show_CW;
          window.onresize = show_CW;

          // Move Window
          var drag_x,drag_y,draging=false

          function drag_move(e){
          if (draging){
             New_CW.show(e.screenX-drag_x, e.screenY-drag_y, CW_width, CW_height);
             return false;
          }
          }

          function drag_down(e){
          if(e.button==2)return;
          if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height)return;
          drag_x=e.clientX;
          drag_y=e.clientY;
          draging=true;
          e.srcElement.setCapture();
          }

          function drag_up(e){
          draging=false;
          e.srcElement.releaseCapture();
          if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height) return;
          CW_top   = e.screenX-drag_x;
          CW_left = e.screenY-drag_y;
          }

          </SCRIPT>
          </HTML>

          電話號(hào)碼的驗(yàn)證

          要求:
            (1)電話號(hào)碼由數(shù)字、"("、")"和"-"構(gòu)成
            (2)電話號(hào)碼為3到8位
            (3)如果電話號(hào)碼中包含有區(qū)號(hào),那么區(qū)號(hào)為三位或四位
            (4)區(qū)號(hào)用"("、")"或"-"和其他部分隔開
            (5)移動(dòng)電話號(hào)碼為11或12位,如果為12位,那么第一位為0
            (6)11位移動(dòng)電話號(hào)碼的第一位和第二位為"13"
            (7)12位移動(dòng)電話號(hào)碼的第二位和第三位為"13"
            根據(jù)這幾條規(guī)則,可以與出以下正則表達(dá)式:
            (^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)


          <script language="javascript">
          function PhoneCheck(s) {
          var str=s;
          var reg=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/
          alert(reg.test(str));
          }
          </script>
          <input type=text name="iphone">
          <input type=button onclick="PhoneCheck(document.all.iphone.value)" value="Check">

          具有在輸入非數(shù)字字符不回顯的效果,即對(duì)非數(shù)字字符的輸入不作反應(yīng)。
          function numbersonly(field,event){
          var key,keychar;
          if(window.event){
             key = window.event.keyCode;
          }
          else if (event){
             key = event.which;
          }
          else{
             return true
          }
          keychar = String.fromCharCode(key);
          if((key == null)||(key == 0)||(key == 8)||(key == 9)||(key == 13)||(key == 27)){
             return true;
          }
          else if(("0123456789.").indexOf(keychar)>-1){
             window.status = "";
             return true;
          }
          else {
             window.status = "Field excepts numbers only";
             return false;
          }
          }

          驗(yàn)證ip

          str=document.RegExpDemo.txtIP.value;
          if(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.test(str)==false)
          {
          window.alert('錯(cuò)誤的IP地址格式');
          document.RegExpDemo.txtIP.select();
          document.RegExpDemo.txtIP.focus();
          return;
          }
          if(RegExp.$1<1 || RegExp.$1>254||RegExp.$2<0||RegExp.$2>254||RegExp.$3<0||RegExp.$3>254||RegExp.$4<1||RegExp.$4>254)
          {
          window.alert('錯(cuò)誤的IP地址');
          document.RegExpDemo.txtIP.select();
          document.RegExpDemo.txtIP.focus();
          return;
          }
          //剔除 如   010.020.020.03 前面 的0
          var str=str.replace(/0(\d)/g,"$1");
          str=str.replace(/0(\d)/g,"$1");
          window.alert(str);



          //一下是取數(shù)據(jù)的類
          //Obj參數(shù)指定數(shù)據(jù)的來源(限定Table),默認(rèn)第一行為字段名稱行
          //GetTableData類提供MoveNext方法,參數(shù)是表的行向上或向下移動(dòng)的位數(shù),正數(shù)向下移動(dòng),負(fù)數(shù)向上.
          //GetFieldData方法獲得指定的列名的數(shù)據(jù)
          //Sort_desc方法對(duì)指定的列按降序排列
          //Sort_asc方法對(duì)指定的列按升序排列
          //GetData方法返回字段值為特定值的數(shù)據(jù)數(shù)組,提供數(shù)據(jù),可以在外部進(jìn)行其他處理
          //Delete方法刪除當(dāng)前記錄,數(shù)組減少一行
          //初始化,Obj:table的名字,Leftlen:左面多余數(shù)據(jù)長度,Rightlen:右面多余數(shù)據(jù)長度,
          function GetTableData(Obj,LeftLen,RightLen){
          var MyObj=document.all(Obj);
          var iRow=MyObj.rows.length;
          var iLen=MyObj.rows[0].cells.length;
          var i,j;

          TableData=new Array();
             for (i=0;i< iRow;i++){
             TableData[i]=new Array();
             for (j=0;j<iLen;j++){
             TableStr=MyObj.rows(i).cells(j).innerText;
             TableStr=TableStr.substring(LeftLen, TableStr.length-RightLen).Trim();
             TableStr=TableStr.replace(/ /gi,"").replace(/\r\n/ig,"");
             TableData[i][j]=TableStr;
             }
             }
            
             this.TableData=TableData;
             this.cols=this.TableData[0].length;
             this.rows=this.TableData.length;
             this.rowindex=0;
          }


          function movenext(Step){
          if (this.rowindex>=this.rows){
          return
          }

          if (Step=="" || typeof(Step)=="undefined") {
          if (this.rowindex<this.rows-1)
          this.rowindex++;
          return;

          }
          else{
             if (this.rowindex + Step<=this.rows-1 && this.rowindex + Step>=0 ){
             this.rowindex=this.rowindex + Step;
             }
             else
             {
             if (this.rowindex + Step<0){
             this.rowindex= 0;
             return;
             }
             if (this.rowindex + Step>this.rows-1){
             this.rowindex= this.rows-1;
             return;
             }
             }
          }
          }


          function getfielddata(Field){
          var colindex=-1;
          var i=0;
          if (typeof(Field) == "number"){
             colindex=Field;
             }
          else
          {
          for (i=0;i<this.cols && this.rowindex<this.rows ;i++){
             if (this.TableData[0][i]==Field){
             colindex=i;
             break;
             }  
             }
          }
             if (colindex!=-1) {
             return this.TableData[this.rowindex][colindex];
             }

          }



          function sort_desc(){//降序
          var colindex=-1;
          var highindex=-1;
          desc_array=new Array();
          var i,j;
          for (n=0; n<arguments.length; n++){
          Field=arguments[arguments.length-1-n];
          for (i=0;i<this.cols;i++){
             if (this.TableData[0][i]==Field){
             colindex=i;
             break;
             }  
          }
             if ( colindex==-1 )
             return;
             else
             {
             desc_array[0]=this.TableData[0];
             for(i=1;i<this.rows;i++){
             desc_array[i]=this.TableData[1];
             highindex=1;
             for(j=1;j<this.TableData.length;j++){
                 if   (desc_array[i][colindex]<this.TableData[j][colindex]){
                 desc_array[i]=this.TableData[j];  
                 highindex=j;
               }
              
             }
               if (highindex!=-1)
               this.TableData=this.TableData.slice(0,highindex).concat(this.TableData.slice(highindex+1,this.TableData.length));                      
             }
          }


          this.TableData=desc_array;
          }
          return;
          }



          function sort_asc(){//升序
          var colindex=-1;
          var highindex=-1;
          var i,j;
          for (n=0; n<arguments.length; n++){
             asc_array=new Array();
             Field=arguments[arguments.length-1-n];
             for (i=0;i<this.cols;i++){
               if (this.TableData[0][i]==Field){
               colindex=i;
               break;
               }  
             }
             if ( colindex==-1 )
               return;
             else
               {
               asc_array[0]=this.TableData[0];
               for(i=1;i<this.rows;i++){
               asc_array[i]=this.TableData[1];
               highindex=1;
                 for(j=1;j<this.TableData.length;j++){//找出最小的列值
                   if   (asc_array[i][colindex]>this.TableData[j][colindex]){
                   asc_array[i]=this.TableData[j];  
                   highindex=j;
                    
                   }
                    
                 }
                   if (highindex!=-1)
                   this.TableData=this.TableData.slice(0,highindex).concat(this.TableData.slice(highindex+1,this.TableData.length));                      
                  
                 }
               }


               this.TableData=asc_array;
          }
          return;
          }



          function getData(Field,FieldValue){
          var colindex=-1;
          var i,j;

          GetData=new Array();
             if (typeof(Field)=="undefined" || typeof(FieldValue)=="undefined" ){
             return this.TableData;
             }
            
             for(j=0;j<this.cols;j++){
                 if   (this.TableData[0][j]==Field){
               colindex=j;
               }
             }
             if (colindex!=-1){
            
             for(i=1;i<this.rows;i++){
                 if   (this.TableData[i][colindex]==FieldValue){
               GetData[i]=new Array();
               GetData[i]=this.TableData[i];
               }
             }
             }
             return GetData;
          }
          function Delete(){
          this.TableData=this.TableData.slice(0,this.rowindex).concat(this.TableData.slice(this.rowindex+1,this.TableData.length));                      
          this.rows=this.TableData.length;
          return;
          }
          function updateField(Field,FieldValue){
          var colindex=-1;
          var i=0;
          if (typeof(Field) == "number"){
             colindex=Field;
             }
          else
          {
          for (i=0;i<this.cols && this.rowindex<this.rows ;i++){
             if (this.TableData[0][i]==Field){
             colindex=i;
             break;
             }  
             }
          }
          if (colindex!=-1) {
             this.TableData[this.rowindex][colindex]=FieldValue;
             }


          }
          function movefirst(){
          this.rowindex=0;
          }
          function movelast(){
          this.rowindex=this.rows-1;
          }
          function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
          GetTableData.prototype.MoveNext = movenext;
          GetTableData.prototype.GetFieldData = getfielddata;
          GetTableData.prototype.Sort_asc = sort_asc;
          GetTableData.prototype.Sort_desc = sort_desc;
          GetTableData.prototype.GetData = getData;
          GetTableData.prototype.Delete = Delete;
          GetTableData.prototype.UpdateField = updateField;
          GetTableData.prototype.MoveFirst = movefirst;

          具體的例子:http://202.119.73.208/NetEAn/com/test/jsprint.htm

          在每個(gè)文本框的onblur事件中調(diào)用校驗(yàn)代碼,并且每個(gè)文本框中onKeyDown事件中寫一個(gè)enter轉(zhuǎn)tab函數(shù)

          //回車鍵換為tab
          function enterToTab()
          {
               if(event.srcElement.type != 'button' && event.srcElement.type != 'textarea'
                 && event.keyCode == 13)
               {
                   event.keyCode = 9;
               }
          }

          有時(shí)候還需要自由編輯表格---
          給大家一個(gè)自由編輯表格的小例子,寫的有點(diǎn)亂,呵呵:)

          //===============================start================================


          <HTML>
          <HEAD>
          <META http-equiv="Content-Type" content="text/html; charset=gb2312">
          <TITLE>測試修改表格</TITLE>
          <STYLE>
          /*提示層的樣式*/
          div
          {
             BORDER-RIGHT: #80c144 1px solid;
             BORDER-TOP: #80c144 1px solid;
             VISIBILITY: hidden;
             BORDER-LEFT: #80c144 1px solid;
             CURSOR: default;
             LINE-HEIGHT: 20px;
             BORDER-BOTTOM: #80c144 1px solid;
             FONT-FAMILY: 宋體;
             font-size:12px;
             POSITION: absolute;
             BACKGROUND-COLOR: #f6f6f6;
             TOP:30px;
             LEFT:30px;
          }
          /*tr的樣式*/
          tr
          {
               font-family: "宋體";
               color: #000000;
               background-color: #C1DBF5;
               font-size: 12px
          }
          /*table腳注樣式*/
          .TrFoot
          {
               FONT-SIZE: 12px;
               font-family:"宋體", "Verdana", "Arial";
               BACKGROUND-COLOR: #6699CC;
               COLOR:#FFFFFF;
               height: 25;
          }
          /*trhead屬性*/
          .TrHead
          {
               FONT-SIZE: 13px;
               font-family:"宋體", "Verdana", "Arial";
               BACKGROUND-COLOR: #77AADD;
               COLOR:#FFFFFF;
               height: 25;
          }
          /*文本框樣式*/
          INPUT
          {
               BORDER-COLOR: #AACEF7 #AACEF7 #AACEF7 #AACEF7;
               BORDER-RIGHT: 1px solid;
               BORDER-TOP: 1px solid;
               BORDER-LEFT: 1px solid;
               BORDER-BOTTOM: 1px solid;
               FONT-SIZE: 12px;
               FONT-FAMILY: "宋體","Verdana";
               color: #000000;
               BACKGROUND-COLOR: #E9EFF5;
          }
          /*button樣式*/
          button
          {
               BORDER-COLOR: #AACEF7 #AACEF7 #AACEF7 #AACEF7;
               BACKGROUND-COLOR: #D5E4F3;
               CURSOR: hand;
               FONT-SIZE:12px;
               BORDER-RIGHT: 1px solid;
               BORDER-TOP: 1px solid;
               BORDER-LEFT: 1px solid;
               BORDER-BOTTOM: 1px solid;
               COLOR: #000000;
          }
          </STYLE>
          </HEAD>
          <BODY>
          <SCRIPT language = "JavaScript">
          <!--全局變量
          //標(biāo)志位,值為false代表未打開一個(gè)編輯框,值為true為已經(jīng)打開一個(gè)編輯框開始編輯
          var editer_table_cell_tag = false;
          //開啟編輯功能標(biāo)志,值為true時(shí)為允許編輯
          var run_edit_flag = false;
          //-->
          </SCRIPT>

          <SCRIPT language = "JavaScript">
          <!--
          /**
          * 編輯表格函數(shù)
          * 單擊某個(gè)單元格可以對(duì)里面的內(nèi)容進(jìn)行自由編輯
          * @para tableID 為要編輯的table的id
          * @para noEdiID 為不要編輯的td的ID,比如說table的標(biāo)題
          * 可以寫為<TD id="no_editer">自由編輯表格</TD>
          * 此時(shí)該td不可編輯
          */
          function editerTableCell(tableId,noEdiId)
          {
          var tdObject = event.srcElement;
          var tObject = ((tdObject.parentNode).parentNode).parentNode;
          if(tObject.id == tableId &&tdObject.id != noEdiId&&editer_table_cell_tag == false && run_edit_flag == true)
          {
             tdObject.innerHTML = "<input type=text id=edit_table_txt name=edit_table_txt value="+tdObject.innerText+" size='15' onKeyDown='enterToTab()'>   <input type=button value=' 確定 ' onclick='certainEdit()'>";
             edit_table_txt.focus();
             edit_table_txt.select();
             editer_table_cell_tag = true;
             //修改按鈕提示信息
             editTip.innerText = "請(qǐng)先點(diǎn)確定按鈕確認(rèn)修改!";  
          }
          else
          {
             return false;
          }
          }

          /**
          * 確定修改
          */
          function certainEdit()
          {
          var bObject = event.srcElement;
          var tdObject = bObject.parentNode;
          var txtObject = tdObject.firstChild;
          tdObject.innerHTML = txtObject.value;
          //代表編輯框已經(jīng)關(guān)閉
          editer_table_cell_tag = false;
          //修改按鈕提示信息
          editTip.innerText = "請(qǐng)單擊某個(gè)單元格進(jìn)行編輯!";
          }

          function enterToTab()
          {
               if(event.srcElement.type != 'button' && event.srcElement.type != 'textarea'
                 && event.keyCode == 13)
               {
                   event.keyCode = 9;
               }
          }

          /**
          * 控制是否編輯
          */
          function editStart()
          {
          if(event.srcElement.value == "開始編輯")
          {
             event.srcElement.value = "編輯完成";
             run_edit_flag = true;
          }
          else
          {
             //如果當(dāng)前沒有編輯框,則編輯成功,否則,無法提交
             //必須按確定按鈕后才能正常提交
             if(editer_table_cell_tag == false)
             {
             alert("編輯成功結(jié)束!");
             event.srcElement.value = "開始編輯";
             run_edit_flag = false;
             }
          }
          }

          /**
          * 根據(jù)不同的按鈕提供不同的提示信息
          */
          function showTip()
          {
          if(event.srcElement.value == "編輯完成")
          {
             editTip.style.top = event.y + 15;
             editTip.style.left = event.x + 12;
             editTip.style.visibility = "visible";  
          }
          else
          {
             editTip.style.visibility = "hidden";  
          }
          }
          -->
          </SCRIPT>
          <TABLE id="editer_table" width="100%" align="center"
               onclick="editerTableCell('editer_table','no_editer')">  
               <TR class="TrHead">
             <TD colspan="3" align="center" id="no_editer">自由編輯表格</TD>  
          </TR>
          <TR>
             <TD width="33%">單擊開始編輯按鈕,然后點(diǎn)擊各單元格編輯</TD>
             <TD width="33%">2</TD>
             <TD width="33%">3</TD>
          </TR>
          <TR>
             <TD width="33%">4</TD>
             <TD width="33%">5</TD>
             <TD width="33%">6</TD>
          </TR>
          <TR>
             <TD width="33%">one</TD>
             <TD width="33%">two</TD>
             <TD width="33%">three</TD>
          </TR>
          <TR>
             <TD width="33%">four</TD>
             <TD width="33%">five</TD>
             <TD width="33%">six</TD>
          </TR>  
               <TR class="TrFoot">
             <TD colspan="3" align="center" id="no_editer">
             <INPUT type="button" class="bt" value="開始編輯" onClick="editStart()" onMouseOver="showTip()" onMouseMove="showTip()" onMouseOut="editTip.style.visibility = 'hidden';">
             </TD>
          </TR>
          </TABLE>
          </BODY>
          <DIV id="editTip">請(qǐng)單擊某個(gè)單元格進(jìn)行編輯!</DIV>
          </HTML>

          /*
          * 功能:表單內(nèi)容格式檢測
          * 參數(shù) obj    為表單名稱(ID)
          *       chktype  為類型,參照函數(shù)內(nèi)釋
          */
          function chk(obj, chktype){
          switch(chktype){
             case 1://判斷是否為空
             if(obj.value == ""){
               alert("請(qǐng)輸入必要的字符。");
               obj.focus();
               obj.onselect();
             }
             break;
             case 2://判斷是否為數(shù)字
             var reg = /^\d+(\.\d+)?$/;
             if(!reg.test(obj.value)){
               alert("請(qǐng)輸入數(shù)字。");
               obj.focus();
               obj.select();
             }
             break;
             case 3://判斷是否為用戶名格式
             var reg = /^[^\d\-_][\w\-]*[^\-_]$/;
             if(!reg.test(obj.value)){
               alert("請(qǐng)輸入正確的格式。");
               obj.focus();
               obj.select();
             }
             break;
             case 4://判斷是否為漢字
             var reg = /^[\u4E00-\u9FA5]*$/;
             if(!reg.test(obj.value)){
               alert("你輸入的不全是漢字。");
               obj.focus();
               obj.select();
             }
             break;
             case 5://判斷是否為郵箱格式
             var reg = /^[^\d\-_][\w\-]*[^\-_]@[^\-][a-zA-Z\d\-]*[^\-](\.[^\-][a-zA-Z\d\-]*[^\-])*\.[a-zA-Z]{3}(\.[a-zA-Z]{2})?$/;
             if(!reg.test(obj.value)){
               alert("你輸入正確的郵箱格式。");
               obj.focus();
               obj.select();
             }
             break;
             case 6://判斷是否為合法日期格式
             var reg = /^(19|20)\d\d\-(0|1)\d\-(0|1|2|3)\d$/;
             if(!reg.test(obj.value)){
               alert("你輸入正確的日期格式。");
               obj.focus();
               obj.select();
             }
             break;
          }
          }



          Abs(number)

          返回絕對(duì)值。

          Array(arglist)

          創(chuàng)建一個(gè)數(shù)組。

          Asc(string)

          返回字符串第一個(gè)字符的ANSI碼。

          Atn(number)

          返回反正弦值。

          CBool (e­xpression)

          轉(zhuǎn)換成Boolean數(shù)據(jù)類型變量。

          CByte (e­xpression)

          轉(zhuǎn)換成Byte數(shù)據(jù)類型變量。

          CCur (e­xpression)

          轉(zhuǎn)換成Currency數(shù)據(jù)類型變量。

          CDate (e­xpression)

          轉(zhuǎn)換成Date數(shù)據(jù)類型變量。

          CDbl (e­xpression)

          轉(zhuǎn)換成Double數(shù)據(jù)類型變量。

          Chr(charcode)

          把ANSI 碼轉(zhuǎn)換成相應(yīng)的鍵盤字符。

          CInt (e­xpression)

          轉(zhuǎn)換成Integer數(shù)據(jù)類型變量。

          CLng (e­xpression)

          轉(zhuǎn)換成Long數(shù)據(jù)類型變量。

          CreateObject(servername.typename)

          創(chuàng)建一個(gè)自動(dòng)對(duì)象。

          CSng (e­xpression)

          轉(zhuǎn)換成Single數(shù)據(jù)類型變量。

          CStr (e­xpression)

          轉(zhuǎn)換成String數(shù)據(jù)類型變量。

          Date

          根據(jù)所用的系統(tǒng)返回時(shí)間。

          DateAdd(interval,number,date)

          向date對(duì)象添加指定的時(shí)間間隔。其中參數(shù)interval 接受下表所示的值。
          posted @ 2009-10-14 23:10 鐵猴 閱讀(449) | 評(píng)論 (0)編輯 收藏

          把一個(gè)日期字符串如“2007-2-28 10:18:30”轉(zhuǎn)換為Date對(duì)象:
          1:
          1var   strArray=str.split("   ");   
          2var   strDate=strArray[0].split("-");   
          3var   strTime=strArray[1].split(":");   
          4var   a=new   Date(strDate[0],(strDate[1]-parseInt(1)),strDate[2],strTime[0],strTime[1],strTime[2])   

          2:
          1var   s   =   "2005-12-15   09:41:30";   
          2var   d   =   new   Date(Date.parse(s.replace(/-/g,   "/")));   
          3

          posted @ 2009-10-13 17:33 鐵猴 閱讀(210) | 評(píng)論 (0)編輯 收藏

          設(shè)計(jì)了文件上傳的工具,但在Tomcat服務(wù)器上訪問中文文件名的文件不能打開,報(bào)找不到文件的錯(cuò)誤,文件名稱在后臺(tái)進(jìn)行了UTF-8的轉(zhuǎn)碼,而在tomcat的server.xml文件中的設(shè)置是這樣的:

          1<Connector port="8080" protocol="HTTP/1.1"    
          2           connectionTimeout="20000"    
          3           redirectPort="8443" URIEncoding="GBK"/>   

          將編碼格式改為UTF-8就可以了:
          <Connector port="8080" protocol="HTTP/1.1"    
                     connectionTimeout
          ="20000"    
                     redirectPort
          ="8443" URIEncoding="UTF-8"/>   
          posted @ 2009-10-12 18:59 鐵猴 閱讀(213) | 評(píng)論 (0)編輯 收藏

          to_date("要轉(zhuǎn)換的字符串","轉(zhuǎn)換的格式")   兩個(gè)參數(shù)的格式必須匹配,否則會(huì)報(bào)錯(cuò)。

          即按照第二個(gè)參數(shù)的格式解釋第一個(gè)參數(shù)。

          to_char(日期,"轉(zhuǎn)換格式" ) 即把給定的日期按照“轉(zhuǎn)換格式”轉(zhuǎn)換。

           

          轉(zhuǎn)換的格式:

          表示year的:y  表示年的最后一位 yy 表示年的最后2位 yyy 表示年的最后3位 yyyy 用4位數(shù)表示年

          表示month的:mm 用2位數(shù)字表示月;mon 用簡寫形式 比如11月或者nov ;month 用全稱 比如11月或者november

          表示day的:dd 表示當(dāng)月第幾天;ddd表示當(dāng)年第幾天;dy 當(dāng)周第幾天 簡寫  比如星期五或者fri;day當(dāng)周第幾天 全寫

          比如星期五或者friday。

          表示hour的:hh 2位數(shù)表示小時(shí) 12進(jìn)制; hh24 2位數(shù)表示小時(shí) 24小時(shí)

          表示minute的:mi 2位數(shù)表示分鐘

          表示second的:ss 2位數(shù)表示秒 60進(jìn)制

          表示季度的:q 一位數(shù) 表示季度 (1-4)

          另外還有ww 用來表示當(dāng)年第幾周 w用來表示當(dāng)月第幾周。

          24小時(shí)制下的時(shí)間范圍:00:00:00-23:59:59

          12小時(shí)制下的時(shí)間范圍:1:00:00-12:59:59

          比如:

          select to_char(sysdate,'yy-mm-dd hh24:mi:ss') from dual   //顯示:08-11-07 13:22:42

          select to_date('2005-12-25,13:25:59','yyyy-mm-dd,hh24:mi:ss') from dual //顯示:2005-12-25 13:25:59

          而如果把上式寫作:select to_date('2005-12-25,13:25:59','yyyy-mm-dd,hh:mi:ss') from dual,則會(huì)報(bào)錯(cuò),因?yàn)樾r(shí)hh是12進(jìn)制,13為非法輸入,不能匹配。

          補(bǔ)充:

          當(dāng)前時(shí)間減去7分鐘的時(shí)間
          select sysdate,sysdate - interval '7' MINUTE from dual
          當(dāng)前時(shí)間減去7小時(shí)的時(shí)間
          select sysdate - interval '7' hour from dual
          當(dāng)前時(shí)間減去7天的時(shí)間
          select sysdate - interval ’7’ day from dual
          當(dāng)前時(shí)間減去7月的時(shí)間
          select sysdate,sysdate - interval '7' month from dual
          當(dāng)前時(shí)間減去7年的時(shí)間
          select sysdate,sysdate - interval '7' year from dual
          時(shí)間間隔乘以一個(gè)數(shù)字
          select sysdate,sysdate - 8*interval '7' hour from dual

           

          Dual偽列

          含義解釋:

          Dual 是 Oracle中的一個(gè)實(shí)際存在的表,任何用戶均可讀取,常用在沒有目標(biāo)表的select語句塊中

          比如,我要獲得系統(tǒng)時(shí)間,則用“select sysdate from dual” 則返回系統(tǒng)當(dāng)前的時(shí)間:2008-11-07 9:32:49,不同系統(tǒng)可能返回日期的格式不一樣。"select user from dual"則返回當(dāng)前連接的用戶。如果是"select 1+2 from dual",則返回結(jié)果:3

          posted @ 2009-10-06 15:37 鐵猴 閱讀(247) | 評(píng)論 (0)編輯 收藏

          為了防止瀏覽器緩存當(dāng)前訪問的JSP動(dòng)態(tài)頁面,可以采用如下的方式進(jìn)行設(shè)置:
          <%
                 // 將過期日期設(shè)置為一個(gè)過去時(shí)間

                  response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");

                  // 設(shè)置 HTTP/1.1 no-cache 頭
                  response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");

                  // 設(shè)置 IE 擴(kuò)展 HTTP/1.1 no-cache headers, 用戶自己添加
                  response.addHeader("Cache-Control", "post-check=0, pre-check=0");

                  // 設(shè)置標(biāo)準(zhǔn) HTTP/1.0 no-cache header.
                  response.setHeader("Pragma", "no-cache");
          %>
          posted @ 2009-10-05 12:09 鐵猴 閱讀(249) | 評(píng)論 (0)編輯 收藏

          僅列出標(biāo)題
          共4頁: 上一頁 1 2 3 4 下一頁 
          主站蜘蛛池模板: 体育| 眉山市| 万源市| 东平县| 郁南县| 和龙市| 临清市| 隆回县| 巍山| 伊通| 玉溪市| 洪泽县| 澎湖县| 榆树市| 宝坻区| 大理市| 宜丰县| 互助| 义马市| 科尔| 常宁市| 五家渠市| 彰武县| 乐业县| 白河县| 莒南县| 麻江县| 酒泉市| 长葛市| 梧州市| 呼和浩特市| 城固县| 南投县| 通州区| 叶城县| 乾安县| 故城县| 裕民县| 郴州市| 太和县| 青田县|