Long型070000L前面0去掉比较大小,token,mysql innodb,properties,switch匹配空字符串对象

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){   //如果没有这个条件判断,会报空指针异常。
                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
            
            
    }

}
原文地址:https://www.cnblogs.com/simpledev/p/4353504.html