package com.heima.lianxi;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Demo3 {
public static void main(String[] args) throws ParseException {
String s1="1993/1/1";
String s2="2016/3/22";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/mm/dd");
Date d1 =sdf.parse(s1);
Date d2 =sdf.parse(s2);
long time =d2.getTime()-d1.getTime();
System.out.println(time/1000/60/60/24/365);
}
}
|
|