刚写出来,其实就是字符串的截取。
package com.swing;
import java.util.Calendar;
import java.util.Timer;
public class NianLing {
public static void main(String[] args) {
String s = "610400199011100000";
s = s.substring(6, s.length()-8);
System.out.println(s);
Calendar cal = Calendar.getInstance();
java.util.Date date = cal.getTime();
String s1 = date.toString();
String s2 = (String) s1.subSequence(s1.length()-4, s1.length());
System.out.println(date);
System.out.println(s2);
Integer int1 = Integer.parseInt(s);
Integer int2 = Integer.parseInt(s2);
Integer age = int2-int1;
System.out.println("age : " + age);
}
}
输出结果:age:22
1990
Fri Dec 14 23:26:52 CST 2012
2012
age : 22