/******************** http://www.anycodes.cn/zh/ ********************/ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Scanner; public class HelloWorld { public static void main(String[] args) throws ParseException { System.out.println("请输入您的出生年月"); Scanner sc = new Scanner(System.in); String input = sc.next(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = sdf.parse(input); Date nowdate = new Date(); long time = nowdate.getTime() - date.getTime(); System.out.println(time / 24 / 3600 / 1000); //1995-8-4 //7585 } }
时间: 2024-09-30 19:41:07