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

    }

}
时间: 2024-08-27 19:50:15

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

Javascript 中的false、0、null、undefined和空字符串对象

在Javascript中,我们经常会接触到题目中提到的这5个比较特别的对象——false.0.空字符串.null和undefined.这几个对象很容易用错,因此在使用时必须得小心. 类型检测 我们下来看看他们的类型分别是什么: [html] view plaincopyprint? <script type="text/javascript"> alert(typeof(false) === 'boolean'); alert(typeof(0) === 'number')

Android - Android Studio 3.0去掉方法参数提示

原文:Android - Android Studio 3.0去掉方法参数提示 升级到3.0之后,最明显的一个就是在调用方法的时候多了一个参数提示.有利有弊,看着不是很舒服.就想去掉. 提示样式如下: 去掉提示: 原文地址: https://blog.csdn.net/student9128/article/details/78141777 原文地址:https://www.cnblogs.com/lonelyxmas/p/10258581.html

字符串分隔 -&gt;连续输入字符串,请按长度为8拆分每个字符串后输出到新的字符串数组; ?长度不是8整数倍的字符串请在后面补数字0,空字符串不处理。

?连续输入字符串,请按长度为8拆分每个字符串后输出到新的字符串数组:?长度不是8整数倍的字符串请在后面补数字0,空字符串不处理. 输入描述: 连续输入字符串(输入2次,每个字符串长度小于100) 输出描述: 输出到长度为8的新字符串数组 输入例子: abc 123456789 输出例子: abc00000 12345678 90000000 import java.util.*; public class Main{     public static void main(String[] ar

Apache Tomcat/6.0.39如何配置连接mysql,JDBC:mysql-connector-java-5.1.30-bin.jar-成功连接心得

http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html 前提:开启TOMCAT,MYsql MySQL DBCP Example0. Introduction Versions of MySQL and JDBC drivers that have been reported to work: MySQL 3.23.47, MySQL 3.23.47 using InnoDB,, MySQL 3.23

《Effective Objective-C 2.0》—(第23-28条)—类别、协议,代理,匿名对象、delegate

第23条:通过委托与数据源协议进行对象间通信 对象之间经常需要相互通信,而通信方式有很多.OC开发者广泛使用一种名叫"委托模式"(Delegate Pattern)的编程设计模式来实现对象间的通信,该模式的主旨是:定义一套接口,某对象若想接收另一个对象的委托,则需遵从此接口,以便称为"委托对象"(delegate).而这"另一个对象"则可以给其委托对象回传一些信息,也可以在发生相关联时间时通知委托对象. 此模式可以将数据与业务逻辑解耦. 在Obj

更改Innodb 数据页大小优化MySQL

更改Innodb 数据页大小优化MySQL http://www.mysqlsupport.cn/change_innodb_page_size/ 更改Innodb 数据页大小优化MySQL 2009年12月13日 Posted by wubx 作者:吴炳锡 来源:http://www.mysqlsupport.cn/ 联系方式: wubingxi#gmail.com 转载请注明作/译者和出处,并且不能用于商业用途,违者必究.         我们知道Innodb的数据页是16K,而且是一个硬性

Mybatis中,Integer类型参数值为0时得到 &quot;&quot;(空字符串)

今日遇到的问题: 查询版本信息时,由于version是Integer类型,所以当前台选择版本为0时,变成了查询了所有的版本信息. sql片段: </if> <if test="version != null and version != '' ">     AND a.version = #{version} </if> 原因: MyBatis因自身原因默认了 Integer类型数据值等于0时 为 ""(空字符串) 解决办法: 1

关于JavaScript中0、空字符串、&#39;0&#39;是true还是false的总结

最近被问到关于js中空字符串是true还是false得问题,一时间没想起来,现在在chrome的console面板上输出代码测试一下. "" == false 结果是true   在js中空字符串与0相等  即空字符串等于false 0 == false  结果是tue   比较的时候 布尔类型的转换成number类型  false 为0  true 为1 “0” == fase 结果是true  字符串准成number Boolean("0") 结果是true 

Struts2.0 去掉action后缀名

刚刚接触Struts2.0,发现默认请求都会带着后缀名:action 就如下图,url地址中会暴露login.action(请原谅struts拼写错误..) 作为一个URL简洁爱(chu)好(nv)者(zuo),一直想把action给去掉,具体方法参考如下: 在struts.xml配置文件中增加一行常量配置: <constant name="struts.action.extension" value=","></constant> 然后重启