/**
* Title:
* Packet:com.lg.handlers
* Description:计算写博客的时间
* Author:LG
* Create Date: 2020/3/31.
* Modify User:
* Modify Date:
* Modify Description:
*/
public class testTime {
public static void main(String[] args) throws ParseException {
System.out.println("您开始写博客的时间(yyyy-mm-dd):");
String str = new Scanner(System.in).nextLine();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse(str);
System.out.println("您放弃写博客的时间(yyyy-mm-dd):");
String str1 = new Scanner(System.in).nextLine();
SimpleDateFormat dsdf1 = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = dsdf1.parse(str1);
long time = date1.getTime()-date.getTime();
time = time/1000/24/60/60;
System.out.println("哇偶,您写博客已经"+time+"天了呢");
}
}
实现结果不重要,重要的是格式一定要规范.哈哈哈~