package balancetime;
import java.text.SimpleDateFormat;
import java.util.Date;
public class test {
public static void main(String[] args) {
String time = "2015-09-22";
//返回时间
Date d = new Date();
SimpleDateFormat sf = new SimpleDateFormat("YYYY-MM-dd");
String da = sf.format(d);
String ss[] = da.split("-");
String ss1[] = time.split("-");
int i1[] = new int[3];
int i2[] = new int[3];
int i3[] = new int[3];
for (int i = 0; i < ss.length; i++) {
i1[i] = Integer.parseInt(ss[i]);
}
for (int y = 0; y < ss.length; y++) {
i2[y] = Integer.parseInt(ss1[y]);
}
for (int k = 0; k < 3; k++) {
i3[k] =Math.abs(i1[k]-i2[k]);
}
int balanceTime =i3[0]*365+i3[1]*30+i3[2];
//返回时间结束
System.out.println(balanceTime);
System.out.println(da);
}
}
|
|