时间类复习

来源:互联网 发布:淘宝二级域名的概念 编辑:程序博客网 时间:2024/05/22 17:15
public class YearDay {    public static void main(String[] args) throws ParseException {        Scanner scanner = new Scanner(System.in);        System.out.println("请输入你的生日");        String line = scanner.nextLine();        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");        Date parse = simpleDateFormat.parse(line);        long time = parse.getTime() - System.currentTimeMillis();        long day = time / 1000 / 60 / 60 / 24;        System.out.println("您已经活了 " + day + "天了");    }}
请输入你的生日1994-11-5您已经活了 8174天了
0 0
原创粉丝点击