Long型070000L前面0去掉比較大小,token,mysql innodb,properties,switch匹配Null 字元串對象

來源:互聯網
上載者:User

標籤:

public class TestJava {        //定義擷取資源檔    private static final ResourceBundle bundle = initBundle();    private static ResourceBundle initBundle(){        return ResourceBundle.getBundle("conf/chinapay", Locale.CHINA);    }    //索引值對    private final static String MERID_UPOP_TEST = bundle.getString("merid.upop.test");         /**     * @param args     */    public static void main(String[] args) {//        Long reqTime =  20150227233132L;  //        Long reqTimeAllowMin =  070000L;  //        Long reqTimeAllowMax =  220000L;  //        Long reqTime = null;                if(reqTime != null && (reqTime % 1000000 >= reqTimeAllowMin && reqTime % 1000000 <= reqTimeAllowMax) ){            System.out.println("OK");        }else{            System.out.println("NO");   //NO        }//        try {            System.out.println(20150227103132L % 1000000);  //103132            System.out.println(20150227143453L % 1000000);  //143453            System.out.println(20150227171104L % 1000000);  //171104            System.out.println(20150302153222L % 1000000);  //153222            //            CommonConstants.TIME_SEC_STR.format("070000");            //            Date dd = CommonConstants.DATETIME_SEC_STR.parse(reqTime.toString());//            CommonConstants.TIME_SEC_STR.format(obj)            //        } catch (ParseException e) {//            // TODO Auto-generated catch block//            e.printStackTrace();//        }  //轉換成日期                        //1.產生token值方法            System.out.println("TOKEN=" + java.util.UUID.randomUUID().toString());  //TOKEN=572061ad-522f-4cc4-8484-aab5f9e44120            System.out.println("TOKEN2=" + java.util.UUID.randomUUID().toString().replace("-", ""));  //TOKEN2=f858b55617c6421bbbc90a66747c62ea                        //2.Long值比較大小            /** 允許自動語音和15分鐘自動拒絕訂單開始的時間點*/            Long REQTIME_ALLOW_MIN =  070000L;  // 7前面這個0需要去掉。            /** 允許自動語音和15分鐘自動拒絕訂單結束的時間點*/            Long REQTIME_ALLOW_MAX =  220000L;  //            //            Long currTime = Long.valueOf(CommonConstants.DATETIME_SEC_STR.format(new Date()));             Long currTime = 20150319050809L;            System.out.println("currTime="+currTime);  //currTime=20150319050809            System.out.println("擷取時分秒="+currTime % 1000000);  //擷取時分秒=50809            System.out.println("是否大於7點="+(currTime % 1000000 >= REQTIME_ALLOW_MIN));  //是否大於7點=true,這個比較值錯誤!!??            System.out.println("是否小於22點="+(currTime % 1000000 <= REQTIME_ALLOW_MAX));  //是否小於22點=true                        /*             * 撥打語音功能點:1.支付訂金成功時,語音通知。(車主同意或拒絕訂單)             * 2.發起延時申請成功,語音通知。(車主同意或拒絕延時申請)             * 3.取車前2小時,未支付租車押金或違章押金,語音通知。(租客支付租車押金和違章押金)             * 4.還車前2小時,語音通知。(租客還車)             */            //050809 這個時間應該是不打電話的。 05:08:09            if(currTime != null && (currTime % 1000000 >= REQTIME_ALLOW_MIN && currTime % 1000000 <= REQTIME_ALLOW_MAX) ){                System.out.println("撥打語音電話通知!");  //撥打語音電話通知!            }else{                System.out.println("夜間10點到第二天早上7點防打擾功能,語音電話屏蔽。");            }            //            Long atest = 050809L;//            Long REQTIME_ALLOW_MIN =  070000L;  //後面4位都是0可以        //            System.out.println("@@@"+(050809l > 70000l));  //編譯通不過。??!!            System.out.println("@@@"+(50809l > 70000l));  //@@@false            System.out.println("@@@"+(50809l > 070000l)); //@@@true  錯誤!!                                    /**             * 3.mysql事務             * InnoDB,MyIsam             * mysql5.6事務支援操作多個表的InnoDB表類型,不允許同時操作InnoDB和MyIsam表。             */                        //4.擷取proerties檔案,注意點:properties檔案中不允許有"" 空格 逗號等。            //merid.upop.test=808080031312345            System.out.println("列印輸出properties檔案key值:" + MERID_UPOP_TEST);            //列印輸出properties檔案key值:808080031394973                        //5.判斷條件及switch匹配string字串。            System.out.println("5.判斷條件及switch匹配string字串");            String rentReason = null; //判斷租車理由,這個條件返回的是 1111111111//            if(rentReason != null){   //如果沒有這個條件判斷,會報null 指標異常。                switch (rentReason) {   //java.lang.NullPointerException                case "周邊旅遊":                    System.out.println("11111");                    break;                case "外地出差":                    System.out.println("22222");                    break;                default:                    System.out.println("33333");  //33333                    break;                }//            }else{//                System.out.println("33333");//            }                                    //下面這樣的寫法是正確的。            String rentReason2 = "周邊旅遊"; //判斷租車理由   "" null            if("周邊旅遊".equals(rentReason2)){                    System.out.println("aaaaaa");   //aaaaaa            }else if("外地出差".equals(rentReason2)){                System.out.println("bbbbbb");            }else {                System.out.println("cccccc");            }                        String rs = null;//            System.out.println(rs.equals("周邊旅遊"));   //null對象調equals會報錯   //java.lang.NullPointerException            System.out.println("周邊旅遊".equals(rs));   //這樣不會報錯,返回false。  false                            }}

 

Long型070000L前面0去掉比較大小,token,mysql innodb,properties,switch匹配Null 字元串對象

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.