package com.hatchet.untils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class NextDay {
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleDateFormat s1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
int aa=8;
Calendar b = Calendar.getInstance();
int a = b.get(Calendar.DATE);
if (a > aa) {
b.add(Calendar.MONTH, 1);
}
// 输入还款日
b.set(Calendar.DATE, aa);
String nowday = sdf.format(b.getTime());
System.out.println("==================:" + nowday);
try {
Date d = new Date();
Date d2 = s1.parse(nowday);
d.getTime();
System.out.println("距离下一个日还有:" + (d2.getTime() - d.getTime())
/ (1000 * 3600 * 24) + "天");
} catch (ParseException e) {
e.printStackTrace();
}
}
}
-----------------------------------------------------------------------------------------------------
运行结果:
==================:2019-04-08
距离下一个日还有:16天