package com.jikexueyuan.ch01;
import java.util.*;
import java.io.Console;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.math.BigInteger;
public class test01{
/* public static void main(String[] args) {
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
int f = 9-(df.format(new Date()));
System.out.println(f);
System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
}
} */
public static void main(String[] args) throws Exception {
//public static String reduceStr(String augend, String augend2) {
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
//System.out.println(sdf.format(new Date()));
String str = (sdf.format(new Date()));
char[] dist = new char[str.length()];
for(int x = str.length() - 1, p = 0; x >= 0; x--){
dist[p++] = str.charAt(x);
}
BigInteger aa =new BigInteger("99999999");
BigInteger bb= new BigInteger(new String(dist));
BigInteger sub=aa.subtract(bb);
System.out.println(sub.toString());
/* String string=sub.toString();
string=string.replace("0","c02");
string=string.replace("1","x03");
string=string.replace("2","f04");
string=string.replace("3","a05");
string=string.replace("4","b06");
string=string.replace("5","e07");
string=string.replace("6","g08");
string=string.replace("7","k09");
string=string.replace("8","s10");
string=string.replace("9","t11");
System.out.println(string); */
//数字转换字符串
String s = sub.toString();
char[] charArray = s.toCharArray();
String[] strings = new String[charArray.length];
for (int k = 0; k < charArray.length; k++) {
String c = String.valueOf(charArray[k]);
int parseInt = Integer.parseInt(c);
if (parseInt == 0) {
strings[k] = "c02";// 这里自己替换
} else if (parseInt == 1) {
strings[k] = "x03";
} else if (parseInt == 2) {
strings[k] = "f04";
} else if (parseInt == 3) {
strings[k] = "a05";
} else if (parseInt == 4) {
strings[k] = "b06";
} else if (parseInt == 5) {
strings[k] = "e07";
} else if (parseInt == 6) {
strings[k] = "g08";
} else if (parseInt == 7) {
strings[k] = "k09";
} else if (parseInt == 8) {
strings[k] = "s10";
} else if (parseInt == 9) {
strings[k] = "t11";
} else {
strings[k] = c;
}
}
StringBuffer sb = new StringBuffer();
for (int k = 0; k < strings.length; k++) {
sb.append(strings[k]);
}
String result = sb.toString();
System.out.println(result);
}
}
转载于:https://blog.51cto.com/liang3391/1632911