工作中用到的

获取当前时间

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date();
            String time = format.format(date);

 

时间戳

 //时间戳
        String nowTime = System.currentTimeMillis()/1000L+"";

 

随机数

//随机数
        Random random = new Random();
        String flag="";
        for(int i=0;i<6;i++){
            flag+=random.nextInt(10);
        }

 

String  s = "";
        for(int i=0;i<6;i++) {
          s+=(int)(Math.random()*10);         
        }
         System.out.println(s);
    }

 

//反转
String string = "abc";
string = new StringBuilder(string).reverse().toString();

 

posted on 2017-07-25 09:48  虫儿aqa  阅读(148)  评论(0编辑  收藏  举报

导航