今天距离你生日的天数

public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的生日");
        int year = scanner.nextInt();
        int month = scanner.nextInt();
        int day = scanner.nextInt();
        getDay(year,month-1,day);
    }
    public static void getDay(int year,int month,int day) {
        Calendar cal = Calendar.getInstance();
        Calendar birth = Calendar.getInstance();
        birth.set(year,month, day);
        long time = cal.getTimeInMillis();
        long birthTime = birth.getTimeInMillis();
        System.out.println((time/1000/60/60/24)-(birthTime/1000/60/60/24));
    }

posted @ 2019-11-21 20:17  James_Harden  阅读(187)  评论(0编辑  收藏  举报