Blame view

CodeTrans.java 1.16 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
package com.meishu.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class CodeTrans {

    public static void main(String[] args) {

        System.out.println("请输入手机号:");
        Scanner scanner = new Scanner(System.in);
        String telephone = scanner.nextLine();
        //String telephone = "15201936167";
        SimpleDateFormat sj1 = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        String current = sj1.format(new Date());
        //System.out.println(current);
        String[]  arrTemp = current.split(" ");

        String[] timeArr = arrTemp[1].split(":");
        Integer first = Integer.valueOf(timeArr[1].substring(0,1));
        Integer second = Integer.valueOf(timeArr[0].substring(0,1));
        Integer  third = Integer.valueOf(timeArr[0].substring(1));
        Integer fourth = Integer.valueOf(timeArr[1].substring(1));
        //System.out.println(first +"===" + second +"===" +third+"===="+fourth);
        System.err.println("验证码是:"+telephone.charAt(first)+"->"+telephone.charAt(second)+"->"+telephone.charAt(third)+"->"+telephone.charAt(fourth));
        System.exit(0);

    }

}