当前位置:编程学习 > JAVA >>

[Java]通过时间锁定程序

 


下面看代码吧……咩哈哈哈哈。。。。

 

 

[java]
String timeString = jsonObject.getString("time").substring(0, 7);  // 双重保险,最好能获得系统时间,以免第三方网站异常时程序无法运行  
                                try { 
                                    URL url = new URL("http://www.bjtime.cn"); 
                                    URLConnection uc = url.openConnection(); 
                                    uc.connect(); 
                                    long time = uc.getDate(); // 获得时间戳  
                                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat( 
                                            "yyyy-MM"); //定义想要的格式  
                                    timeString = simpleDateFormat.format(time); 
                                } catch (Exception e) { 
                                    e.printStackTrace(); 
                                } 
                                if (timeString.equals("2012-12")) //我把时间设定成为2012年12月有效  
                                    getData(); 
                                else { 
                                    Message message = handler 
                                            .obtainMessage(Constant.OVERDUE_DIALOG); 
                                    message.sendToTarget(); // 给个程序过期的提示吧!  
                                } 

String timeString = jsonObject.getString("time").substring(0, 7);  // 双重保险,最好能获得系统时间,以免第三方网站异常时程序无法运行
        try {
         URL url = new URL("http://www.bjtime.cn");
         URLConnection uc = url.openConnection();
         uc.connect();
         long time = uc.getDate(); // 获得时间戳
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
           "yyyy-MM"); //定义想要的格式
         timeString = simpleDateFormat.format(time);
        } catch (Exception e) {
         e.printStackTrace();
        }
        if (timeString.equals("2012-12")) //我把时间设定成为2012年12月有效
         getData();
        else {
         Message message = handler
           .obtainMessage(Constant.OVERDUE_DIALOG);
         message.sendToTarget(); // 给个程序过期的提示吧!
        }


 

补充:软件开发 , Java ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,