CodeTrans.java
1.16 KB
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);
}
}