标签:小代码
/******************** 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 } }
标签:小代码
原文地址:http://wzsts.blog.51cto.com/10251779/1771971